Java.net.SocketException: Too many open files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.