Any tips on debugging Java to find the reason “Too many files open”,

I am developing in a linux environment, and the system is designed to work continuously for a long period of time. After a nightly test, we see a FileNotFoundException with the message "Too Many Files Open". We started to log the output of the lsof command at different times in the system to see if we can see what is happening. We noticed that many unnamed pipes are open. Therefore, I decided that this is due to the fact that file streams do not close. I searched the source for any Stream objects used and made sure that they all closed in the finally {} block. Are there any other types of Java objects that I could find so that I could not close, which would open all of these unnamed pipes?

Also, my ulimit is 1024, and I also looked for * Writer and made sure they all close too.

+5
source share
3 answers

YourKit may be worth a look. Its probes are designed to solve such problems, although I have never had the opportunity to try this functionality.

+2
source

, ulimit ulimit -n. 1024 - , . , lsof , FileNotFound Runtime.exec( "lsof" ) , .

0

Other classes that file descriptors can leak are FileChanneland RandomAccessFile- the latter does not even have a finalizer, so its leaks can be permanent.

0
source

All Articles