Max number of open file descriptors is too low

Bjorn Gustavsson <>
Wed Sep 28 13:48:56 CEST 2005


The code is correct.

max_files will be adjusted downwards only if select() is actually used.

On Mac OS X select() IS used. On Mac OS X 10.3, poll() is actually
emulated using select(), so we call select() ourselves. On Mac OS X 10.4,
there is a real poll() but it does not work for devices (including the
terminal), so we use select() instead.

/Bjorn

Joel Reymont <> writes:

> This won't work on Unix. Assuming that MAX_FILES() will return
> ERL_MAX_PORTS, it will be reset back to FD_SETSIZE. I had this
> problem on the Mac and had to edit header files.
> 
> Could this be a bug?
> 
>  From erts/emulator/unix/sys.c
> 
> void
> erl_sys_init(void)
> {
> ...
>      if ((max_files = MAX_FILES()) < 0)
>          erl_exit(1, "Can't get no. of available file descriptors\n");
> 
>      /* Note: this is if MAX_FILES() differ from FD_SETSIZE which it */
>      /* does by deafult on e.g. BSDI  */
> #if defined(USE_SELECT) && defined(FD_SETSIZE)
>      if (max_files > FD_SETSIZE)
>          max_files = FD_SETSIZE;
> #endif
> ..
> }
> 
> 
> On Sep 27, 2005, at 4:06 PM, Bengt Kleberg wrote:
> 
> > On 2005-09-27 15:46, Joel Reymont wrote:
> >
> >> Folks,
> >> Erlang hardcodes the maximum number of open file descriptors and  I
> >> think the default number is too low. At least on Windows it is.
> >>
> >
> > ...deleted
> >
> >> Would the Erlang/OTP consider upping the number of descriptors on
> >> Windows to something like 1024*8 or 1024*10?
> >>
> >
> > greetings,
> >
> > have you tried this:
> >
> > (http://www.erlang.se/doc/doc-5.4.8/doc/efficiency_guide/
> > part_frame.html)
> >
> > Open files, and sockets
> >     The maximum number of simultaneously open files and sockets
> > depend on the maximum number of Erlang ports available, and
> > operating system specific settings and limits.
> >
> > Open ports
> >     The maximum number of simultaneously open Erlang ports is by
> > default 1024. This limit can be raised up to at most 268435456 at
> > startup (see environment variable ERL_MAX_PORTS in erlang(3)) The
> > maximum limit of 268435456 open ports will at least on a 32-bit
> > architecture be impossible to reach due to memory shortage.
> >
> >
> > bengt
> >
> >
> 
> --
> http://wagerlabs.com/
> 
> 
> 
> 

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list