Thursday, January 30, 2014

Unable to create new native thread and max user processes

very often i have seen "Unable to create new native" error when i am writing Multi threaded programming in Java on Linux box


The error stack usually shout like below!
ava.lang.OutOfMemoryError: unable to create new native thread 
        at java.lang.Thread.start0(Native Method) 
        at java.lang.Thread.start(Thread.java:691) 

One of the reason for this is number of Max User Processes for given user in your Linux box is very low!
you can check the number of Max User Processes by typing the command ulimit -a



[vanji@myMachine area51]$ ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 95153
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 32768
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

So how do we increase the max user processes ?


Follow the step:

vi /etc/security/limits.conf  and add below the menstioed

*          soft     nproc          65535
*          hard     nproc          65535
*          soft     nofile         65535
*          hard     nofile         65535

Save and Exit check the user max processes ulimit



[vanji@myMachine area51]$ ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 95153
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 32768
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) 65535 
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited





No comments:

Post a Comment