Most of the reason is because the program does not close open resource connections, such as RMI, database, and other connections. It is also possible to have more than the default number of open files in Linux itself.
First, start with the Linux setup
(1) ulimit-a (view resource settings)
Core file size (blocks,-c) 0data seg size (Kbytes,-D) unlimitedscheduling priority (-e) 0file size (blo Cks,-F) unlimitedpending signals (-I ) 30525max locked memory (Kbytes, L) 64max memory size (Kbytes,-m) Unli Mitedopen files (-N) 1024pipe size (bytes,-p) 8POSIX message Queues (bytes,-Q) 819200real-time priority (-R) 0stack size (Kbytes,-s) 10240cpu time (seconds,-t) Unlimitedmax user Processes (-u) 1024virtual memory (Kbytes,-V) Unlimitedfile Locks (-X) Unlimited
Open files Default is 1024
In order for the server restart setting to take effect, a permanent change method is taken.
Vim/etc/security/limits.conf
Added at the end of the document
* Soft Nofile 65535* hard nofile 65535
(2) vim/etc/pam.d/login
Added at the end of the document
Session required/lib/security/pam_limits.so
Second, the procedure
Remember to close the resource connection in the finally statement block, such as:
FINALLY{IF (connector! = null) {Connector.close ();}}
Java.net.SocketException: Too many open files