Re: "Too many open files in system"


Subject: Re: "Too many open files in system"
From: Paul Schinder (schinder@pobox.com)
Date: Fri Sep 01 2000 - 09:41:35 MDT


At 6:53 AM -0700 9/1/00, Chuq Von Rospach wrote:
>got this message last night while the system was busy sending a
>bunch of end-of-month email.
>
>Looks like the kernel file table is too small. How do I increase the
>size of this under linux?

Well, there's a /proc/sys/fs/file-max, and I'll bet that this is one
of those things where you can change the kernel parameter simply by
echoing into this file. Sure enough, in
/usr/src/linux/Documentation/filesystems/proc.txt there's:

----------
file-nr and file-max
--------------------

The kernel allocates file handles dynamically, but doesn't free them again at
this time.

The value in file-max denotes the maximum number of file handles that the
Linux kernel will allocate. When you get a lot of error messages about running
out of file handles, you might want to raise this limit. The default value is
4096. To change it, just write the new number into the file:

   # cat /proc/sys/fs/file-max
   4096
   # echo 8192 > /proc/sys/fs/file-max
   # cat /proc/sys/fs/file-max
   8192

This method of revision is useful for all customizable parameters of the
kernel - simply echo the new value to the corresponding file.

The three values in file-nr denote the number of allocated file handles, the
number of used file handles, and the maximum number of file handles. When the
allocated file handles come close to the maximum, but the number of actually
used ones is far behind, you've encountered a peak in your usage of file
handles and you don't need to increase the maximum.

However, there is still a per process limit of open files, which unfortunately
can't be changed that easily. It is set to 1024 by default. To change this you
have to edit the files limits.h and fs.h in the kernel source tree. Finally,
change the definition of NR_OPEN and recompile the kernel.
-----------

So it depends on what caused your problem. If you hit the
application's limit, it looks like you need to recompile the kernel.
Otherwise, try raising file-max.

>
>--
>Chuq Von Rospach - Plaidworks Consulting (mailto:chuqui@plaidworks.com)
>Apple Mail List Gnome (mailto:chuq@apple.com)
>
>And they sit at the bar and put bread in my jar
>and say 'Man, what are you doing here?'"

-- 
--
Paul Schinder
schinder@pobox.com



This archive was generated by hypermail 2a24 : Fri Sep 01 2000 - 09:46:43 MDT