It is important to ensure that files that are opened always get closed. Failing to close files can result in file descriptor leaks. You can detect a file descriptor leak in two different ways:
You may notice a lot of
IOExceptions
with the message “Too many open files.”During load testing, you periodically run a profiling script, such as
lsof
(on UNIX), and you notice that the list of file descriptors grows continually. See Solaris Profiling Tools in the Monitoring Site Performance chapter.
File descriptor leaks can also lead to a variety of failures on attempts to open properties files, sockets, etc. If your error log contains a lot of chaotic-looking error messages, the presence of a file descriptor leak is one thing to check.