Resolution-java.lang.OutOfMemoryError:unable to create new native thread

Source: Internet
Author: User

Often encountered this problem, the general idea is to change the configuration startup parameters, to find ways to increase the number of parameters, it is possible to avoid memory overflow. But the effect is still basically going wrong. I found an article on the internet to solve this problem click the Open Link main point of view for

The intrinsic reason for this anomaly is that we have created too many threads, and the number of threads that can be created is limited, causing the exception to occur. A detailed calculation formula for the number of threads that can be created such as the following: (maxprocessmemory-jvmmemory-reservedosmemory)/(threadstacksize) = numbers of Threadsmaxprocessmemory refers to the maximum memory of a process jvmmemory the         JVM memory reservedosmemory  reserved operating system memory Threadstacksize      


To solve this problem: 1, if there is a bug in the program, causing the creation of a large number of unnecessary threads or the thread is not collected in a timely manner, then the bug must be resolved and the change of the number of parameters will not solve the problem. 2, assuming that the program does require a large number of threads, the existing settings do not meet the requirements, you can change the maxprocessmemory,jvmmemory,threadstacksize these three factors, to add the number of threads that can be created: a, Maxprocessmemory uses 64-bit OS B, jvmmemory   reduces jvmmemory allocation C, threadstacksize  reduces the stack size of a single thread

This point of view let me start also very puzzled, but carefully look at the error log

# There is insufficient memory for the Java Runtime environment to continue.# Native memory allocation (malloc) failed to Allocate 2334888 bytes for chunk::new# A error report file with more information is saved as:# D:\xxx_err_pid1904.log
In view of the specific PID log, it is surprising to find that the solution is the same as the theory mentioned above

# There is insufficient memory for the Java Runtime environment to continue.# Native memory allocation (malloc) failed to Allocate 2355528 bytes for chunk::new# Possible reasons:# The system was out of physical RAM or swap space# in + bit mode, the process size limit is hit# Possible solutions:# Reduce memory load on the system# increase physical memory or swap space# Check if swap backing store is full# use n bit Java on a os# <span style= "color: #FF0000;" >decrease Java Heap Size (-XMX/-XMS) </span># <span style= "color: #FF0000;" >decrease number of Java threads</span># <span style= "color: #FF0000;" >decrease Java Thread Stack sizes (-XSS) </span># Set Larger code cache with-xx:reservedcodecachesize=# this OU Tput file May is truncated or incomplete.## out of Memory Error (allocation.cpp:328), pid=4308, tid=6720## JRE Version:7 .0_25-b16# Java Vm:java HotSpot (TM) Server VM (23.25-b01 mixed Mode windows-x86) # Failed to write Core dump. Call to MiniDumpWriteDump () failed#
Notice the red Mark on the top.
The Tomcat service start-up has been reduced by half and changed to the following number of references, for example

-xms256m-xmx512m-xss1m

Start the service again, and immediately observe the Tomcat process in task management specific, memory usage is less than the maximum value of memory usage increases, and gradually fall back to a lower value. The CPU usage is higher than the error value when it starts, and returns to normal after startup. And the service can start normally.

Combined with the above situation, and in the simple practice, I think the theory quoted in the article should be justified, the following again encountered this exception, it is best to try to reduce the relevant configuration parameters, will probably solve the problem.

Resolution-java.lang.OutOfMemoryError: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.