Max User Processes and Java OutOfMemoryError "unable to create new native thread": Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:


* [[Java Troubleshooting#Subjects|Java Troubleshooting]]
* [[Java Troubleshooting#Subjects|Java Troubleshooting]]
* [[Java_Threads#Java_Threads_and_Linux_Processes|Java Threads and Linux Processes]]


=Overview=
=Overview=
Line 12: Line 13:
</pre>
</pre>


java.lang.OutOfMemoryError "unable to create new native thread" is usually the result of the java process attempting to create more threads than the system "max user processes" limit.
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 "[[Linux_Process_Management_Concepts#Maximum_Number_of_Processes_Allowed_on_the_System|maximum number of processes allowed on a system]]" and "[[Linux_Process_Management_Concepts#Maximum_Number_of_Processes_Available_to_a_Single_User|maximum number of processes available to a single user]]". To figure out the number of threads, read it over JMX from the [[JMX#Thread_Monitoring_and_Management|"java.lang:type=Threading" platform MBean]], or externally from the O/S-level representation of the Java process, as described here [[Linux_Process_Information#Threads|/proc/<pid>/status]].


To figure out the number of threads, monitor the JVM, or use MCS, or read that number from /proc <font color=red>TODO: how?</font>.
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 [[Ulimit#To_Set_A_Value|the maximum number of processes allowed to a single user can be changed]].
 
Then, read the number of maximum user processes allowed ''for the UNIX user that runs that JVM''. Look for "max user processes":
 
<pre>
[jbossusr@tcffevt1r6ap02 ~]$ ulimit -an
 
core file size          (blocks, -c) 0
data seg size          (kbytes, -d) unlimited
scheduling priority            (-e) 0
file size              (blocks, -f) unlimited
pending signals                (-i) 127470
max locked memory      (kbytes, -l) 64
max memory size        (kbytes, -m) unlimited
open files                      (-n) 16384
pipe size            (512 bytes, -p) 8
POSIX message queues    (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time              (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
</pre>
 
or
 
<pre>
ulimit -u
</pre>
 
Then increase that number in <tt>/etc/security/limits.conf</tt>.
 
Also see:
 
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[Ulimit#.2Fetc.2Fsecurity.2Flimits.conf|<tt>ulimit /etc/security/limits.conf</tt>]]
</blockquote>


For more details on how Java threads map onto Linux processes, see {{Internal|Java_Threads#Java_Threads_and_Linux_Processes|Java Threads and Linux Processes}}
For more details on how Java threads map onto Linux processes, see {{Internal|Java_Threads#Java_Threads_and_Linux_Processes|Java Threads and Linux Processes}}

Latest revision as of 04:49, 22 April 2017

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