Problem of "Too many open files"

Discussion in 'Perl Misc' started by Yash, Jun 19, 2004.

  1. Yash

    Yash Guest

    Hi,
    I am facing a problem with a Perl 5.6.1 program on HP-Ux 11i.
    My program reads lines from a set of hundreds of files and based on a
    particular field in every line, redistributes the lines to a new set
    of files.
    A new file is created using:
    $fh{$timePartition} = IO::File->new("> $ENDIR/$timePartition.new") or
    print LOGFILE "$!\n";


    While running the program, I get an error at the above line saying
    "Too many open files"

    This is because I close the file descriptors after I am done with all
    the input files.

    Is there a way I can get around the problem from within Perl, by
    increasing the value of some special variable?
    If that is not possible, what system parameter should I increase to
    avoid the problem?

    Thanks
    Yash, Jun 19, 2004
    #1
    1. Advertising

  2. Yash

    Ben Morrow Guest

    Quoth (Yash):
    > Hi,
    > I am facing a problem with a Perl 5.6.1 program on HP-Ux 11i.
    > My program reads lines from a set of hundreds of files and based on a
    > particular field in every line, redistributes the lines to a new set
    > of files.
    > A new file is created using:
    > $fh{$timePartition} = IO::File->new("> $ENDIR/$timePartition.new") or
    > print LOGFILE "$!\n";


    I wouldn't use IO::File... nowadays it has been superseded by lexical FHs:

    open $fh{$timePartition}, '>', "$ENDIR/$timePartition.new"
    or print LOGFILE "can't create '$ENDIR/$timePartition.new': $!\n";

    I would also consider overriding CORE::GLOBAL::die to write to the logfile and
    using that instead.

    > While running the program, I get an error at the above line saying
    > "Too many open files"
    >
    > This is because I close the file descriptors after I am done with all
    > the input files.
    >
    > Is there a way I can get around the problem from within Perl, by
    > increasing the value of some special variable?


    No.

    > If that is not possible, what system parameter should I increase to
    > avoid the problem?


    man ulimit

    Ben

    --
    Joy and Woe are woven fine,
    A Clothing for the Soul divine William Blake
    Under every grief and pine 'Auguries of Innocence'
    Runs a joy with silken twine.
    Ben Morrow, Jun 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Collin VanDyck

    (Too many open files)

    Collin VanDyck, Oct 13, 2003, in forum: Java
    Replies:
    5
    Views:
    2,856
    Collin VanDyck
    Oct 14, 2003
  2. Cathy  Hui
    Replies:
    6
    Views:
    9,042
    Wiseguy
    Mar 4, 2005
  3. bond
    Replies:
    1
    Views:
    3,181
    Mark Jeffcoat
    Jun 28, 2007
  4. bond
    Replies:
    3
    Views:
    22,393
  5. AMD

    Too many open files

    AMD, Feb 4, 2008, in forum: Python
    Replies:
    9
    Views:
    617
Loading...

Share This Page