How do I fix Out of Memory Unable to Create Native thread error?

Matthew Wang
2020-09-15 23:09

Subject 
Troubleshoot the "Unable to create Native Thread" JVM error 

Affected Versions
6.X

Description

You may encounter the following error in your logs:
 java.lang.OutOfMemoryError: unable to create new native thread

Some items need to be reviewed to solve this problem.

Resolution

How to resolve the error:

-Increase the number of max open files or processes in the /etc/security/limits.conf, and restart the application. For example:

*               hard    nofile          65535
*               soft    nofile          65535
*               hard    noproc          unlimited
*               soft    noproc         unlimited

**In SUSE Linux, you will also need to set the "DefaultTasksMax=65535" in the /etc/systemd/system.conf, and restart the machine.

-Increase system max threads:
echo 100000 > /proc/sys/kernel/threads-max

Sources:
https://www.suse.com/support/kb/doc/?id=000015901
http://www.mastertheboss.com/jboss-server/jboss-monitoring/how-to-solve-javalangoutofmemoryerror-unable-to-create-new-native-thread
https://dzone.com/articles/troubleshoot-outofmemoryerror-unable-to-create-new