|
Resolve Too Many Open Files
If you have exceptions pointing to having too many open files, you might have an operating system resource problem. See how to fix it
by Laurent Goldsztejn
December 3, 2004
File descriptors are unique to processes to identify open files of different types, including sockets or pipes. Exceptions indicating too many open files are thrown when the operating system runs short of file descriptors. However, running out of file descriptors is often the symptom of a more complex issue where resources associated with these files are not maintained correctly. Let's see how we can troubleshoot issues that lead to exceptions like this:
java.net.SocketException: Too many open
files
at java.net.PlainSocketImpl.accept(
Compiled Code)
at java.net.ServerSocket.implAccept(
Compiled Code)
at java.net.ServerSocket.accept(
Compiled Code)
at weblogic.t3.srvr.ListenThread.run(
Compiled Code)
…
and like this:
java.io.IOException: Too many open files
at java.lang.UNIXProcess.forkAndExec(
Native Method)
at java.lang.UNIXProcess.(
UNIXProcess.java:54)
at java.lang.UNIXProcess.forkAndExec(
Native Method)
at java.lang.UNIXProcess.(
UNIXProcess.java:54)
at java.lang.Runtime.execInternal(
Native Method)
at java.lang.Runtime.exec(
Runtime.java:551)
at java.lang.Runtime.exec(
Runtime.java:477)
at java.lang.Runtime.exec(
Runtime.java:443)
…
The first exception is thrown when the error affects the underlying TCP protocol, while the second is thrown when the error affects an I/O operation. Both are symptoms of a similar problem that blocks the server, which we'll address here with investigative techniques.
The second exception represents a scenario in which the JVM process lacks file descriptors, although it needs new ones to duplicate the parent process's file descriptors during the execution of a forkAndExec() subroutine. For each process, the operating system kernel maintains a file descriptor table where all file descriptors are indexed in the u_block structure.
Let's start with a refresher on file descriptors. A file descriptor is a handle represented by an unsigned integer used by a process to identify an open file. It is associated with a file object that includes information such as the mode in which the file was opened, its position type, its initial type, and so on. This information is called the context of the file.
Back to top
|