I have a java app on a large instance that will spawn up to 800 threads. I can run the application fine as user "root" but not as another user which I created. I get the deadly.

java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:657)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1325)

nightmare. I have tried increasing the stack size already in limits.conf to no avail. Please, help me out. What is different here for the root and other user?

link|improve this question
Take a look at the output of ulimit -a for each user and see if there are any notable differences. – cyberx86 Feb 2 at 0:13
They are exactly the same. and thats what bugs me – vinchan Feb 2 at 0:27
I'd recommend using strace to identify the underlying native call that's throwing an error so you can know exactly what you're looking at. – Kyle Smith Feb 2 at 3:54
I think it will be helpful if you tell us more about your hardware/OS – Khaled Feb 2 at 9:15
have you heard of thread worker pools at all? many native threads are bad for a servers health!!! – The Unix Janitor Feb 2 at 10:12
show 1 more comment
feedback

2 Answers

For some reason, setting the max number of processes higher seems to solve it, although I am sure there is only one process running with a lot of threads. Posting my final configs.

$ ulimit -u 81920

$ 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) 59377
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 100000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 81920
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
link|improve this answer
2  
Linux threads do consume process IDs, so this behaviour is quite normal. – Hubert Kario Feb 3 at 23:28
feedback

Have you tried java -Xmx1024m yourapp ?

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.