How many threads can be created by the JVM: Unable to create new native thread

Source: Internet
Author: User

Recent tests require a long connection to the server. These data need to reach 100W long connection, test client. A thread to keep the connection. Find Linuxserver Creator By default 3200 when multiple threads. This error will get "java.lang.OutOfMemoryError:unable to create new native thread. And, at this time the whole system can not innovate new threads, can not connect the terminal, can not run no matter what command.

It seems that there is not enough memory. But there is still a surplus of real memory. Proven. Some kernel parameters for Linux limit the creation of new threads.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbwljbhvuzw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">



Because you want to keep a long connection. Change all first the client guarantees greater allocation of port range changes/etc/sysctl.conf joins such a line: Net.ipv4.ip_local_port_range = 1024 61000


Change the system's number of parameters

echo " 100000 " >/proc/sys/kernel/threads-max
echo " 100000 " >/proc/sys/kernel/pid_max     (default 32768)
echo "200000" >/proc/sys/vm/max_map_count (Default 65530)


Change/etc/security/limits.conf* -Nproc 999999
* -Nofile 999999
Ps:nproc is the size of the max user processes that changes the system; Nofile is the size of the open files. In addition, the Linux 2.6.25 kernel has a macro definition that defines the maximum value for this value, which is 1024*1024, which is exactly 1 million, and after the 2.6.25 kernel and beyond. This value can be set by/proc/sys/fs/nr_open, except that 999999 is sufficient.
Very many people may come across. Just to start more than 32,000 threads can no longer be a lot of other threads, in fact, Pid_max = 32768 is limited to


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

How many threads can be created by the JVM: Unable to create new native thread

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.