Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using a comercial application which contains a large amount of perl code. The application hangs when a specific number of concurrent users attach to it. The vendor claims the problem is due to Perl having a "filehandle limit of 1024" They claim this will be resolved with the next release of Perl. Sounds bogus to me. I have searched and searched and cannot find any reference to such a limitation. Can anyone confirm or deny? Thanks.

Replies are listed 'Best First'.
•Re: FIlehandle Limit
by merlyn (Sage) on Jun 19, 2002 at 19:24 UTC
    That's not a Perl limit, that's an OS limit (or an OS library limit).

    Praytell, what kind of thing are you doing where you need to keep a fileposition on 1024 files?

    -- Randal L. Schwartz, Perl hacker

      Thanks for your reply. I, unfortunately, cannot say why the application requires 1024 filehandles. I am a humble project manager with no programming skills whatsoever.
(Revelation) Re: FIlehandle Limit
by Revelation (Deacon) on Jun 19, 2002 at 19:34 UTC
    Actually, there is such a limitation, which as merlyn duely noted is an OS limitation, but it can be handled rather readily with the perl module FileCache. The module is rather simple to use, and modifieng the code should take very little time. In fact, I'd say you could do it in a few minutes, yourself.

    Note: FileChache does not actually change your systems filehandle limit, rather it proceeds to open and close filehandles allowing you to write to files :) You could probably modify your system's Kernel to be able to open more files as well.

    Another Note: I'm pretty sure this module should come standard with perl, but can't guarantee that.
    Gyan Kapur
    gyan.kapur@rhhllp.com
Changing kernel filehandle limits (no Perl required)
by pjf (Curate) on Jun 20, 2002 at 00:36 UTC
    As already mentioned, this is a OS limit, not a Perl limit. Programmers of all creeds have been encountering the joys of hitting filehandle ceilings for years.

    In fact, this is such a common problem for heavily used proxies that there's an entire section of the squid FAQ devoted to how to increase your filehandle limit.

    Head on over to the squid FAQ (Troubleshooting) and scroll down to section 10.4 (Running out of filedescriptors). It covers how to solve the problem on a variety of UNIX-flavoured operating systems.

    Paul Fenwick
    Perl Training Australia