Eager to Code, Enjoy to Debug ~ Embark into Each Stage with Your Heart

Too many open files

Posted by: Chyne on: May 20, 2009

It seems that the “Too many open files” error is a common problem for Linux users. This error can be easily occurs if you had set the maximum number of open files which is allowed by the Operating System is too low and the kernel is longer can handle it anymore.

The following errors will appear in the log files if you are hitting into this problem:-


Caused by: java.io.IOException: Too many open files
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1793)
at javax.imageio.stream.FileCacheImageOutputStream.(FileCacheImageOutputStream.java:67)
at com.sun.imageio.spi.OutputStreamImageOutputStreamSpi.createOutputStreamInstance(OutputStreamImageOutputStreamSpi.java:50)
at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:393)
... 66 more

In order to fix the problem, what you need to do in the first place is to check the current maximum number of file descriptors:-

# cat /proc/sys/fs/file-max

The value sets in the /proc/sys/fs/file-max is for the overall limit of files that can be opened across all files. In order to increase the maximum number of file descriptors, you can ‘cat’ a number to this file:-

# echo "200000" >/proc/sys/fs/file-max

If this doesn’t help much, you might need to consider increasing the ulimit open file value as well. The ulimit sets the number of files that can be open per process. For example, you can increase the ulimit file value as following:

# ulimit -n 16384

If you need other information for troubleshooting this, there are several Unix commands that you can use to gather more information about this problem:

Figure out the number of current open file descriptor limit

# more /proc/sys/fs/file-max

Shows the total of open file descriptors are currently being used

# more /proc/sys/fs/file-nr

Shows the list of current open files

# lsof

The total files descriptors used by specific program

# lsof –p pid | wc –l

* Note: the <pid> can be obtained when you are using the #lsof command

Other useful readings about file descriptors and finding open files with lsof:

Leave a Reply

Email Subscription

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Friday’s Java Snack


In Java, "thread" means:

  • An instance of class java.lang.Thread
  • A thread of execution


An instance of Thread is just an object that has variables and methods, and lives and dies on the heap.
 
A thread of execution is an individual process that has its own call stack (one thread per call stack).

 

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Archives


  • system_forex_: I like this website very much. This is such a outstanding web. And it is not like other money oriented website, the message here is genuinely impo
  • Faruk: its very very very fine solution perfect
  • blackhawk: Nice tip -- thanks for sharing

StatCounter

free hit counters