Max User Processes and Java OutOfMemoryError "unable to create new native thread"

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method) [rt.jar:1.8.0_51]
        at java.lang.Thread.start(Thread.java:714) [rt.jar:1.8.0_51]
        ...

java.lang.OutOfMemoryError "unable to create new native thread" is usually the result of the java process attempting to create more threads than what is allowed at user or system level. For more details, see "maximum number of processes allowed on a system" and "maximum number of processes available to a single user". To figure out the number of threads, read it over JMX from the "java.lang:type=Threading" platform MBean, or externally from the O/S-level representation of the Java process, as described here /proc/<pid>/status.

The number of threads cannot exceed the value returned by "ulimit -u". The same value is reported as "max user processes " by "ulimit -a". This is how the maximum number of processes allowed to a single user can be changed.

For more details on how Java threads map onto Linux processes, see

Java Threads and Linux Processes