UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2006-05-17 04:45 AM

Lloyd
Member
Registered: 2006-02-13
Posts: 53

Re: Maximum no of files can be opened

In linux what is the maximum number of files can be opened at a time (for the whole system) and for one process? Can I change the maximum limit?

Offline

#2 2006-05-17 01:34 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Maximum no of files can be opened

For the whole system, it's configurable via "/proc/sys/fs/file-max" (at least on 2.4.x)...
On a per-process basis, it's configurable via "ulimit -n" or setrlimit(RLIMIT_NOFILE)...
But, there may also be compiled-in kernel maximums that you can't exceed, so you
may not be able to just arbitrarily increase without limit (without recompiling your
kernel to support the desired new max)...

Offline

#3 2006-05-17 06:21 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Maximum no of files can be opened

"/proc/sys/fs/file-max" works for 2.6 too. I'm not aware of any hardcoded kernel limits on the number of opened files, I don't think there are any. The per process bitmask which keeps track of which fds are open is dynamically grown when needed. Of course there are practical limits.

Offline

#4 2006-05-17 07:08 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Maximum no of files can be opened

Maybe in 2.6 they got rid of the fixed per-process limit too, then...  In 2.4, I'm
pretty sure there is some compiled-in fixed per-process upper limit...  I think it's
"NR_OPEN"...  (Though, in my local kernel headers, it looks like it's currently
defined as "(1024 * 1024)", so you probably won't need to go above 1M open
FDs in a single process anyway, I hope! ;-))  I vaguely remember that in 2.2.x, the
fixed limit was MUCH lower, and people did indeed often need to recompile their
kernels with larger values...

Offline

Board footer

Powered by FluxBB