Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When running this program thread-limit.c on my dedicated debian server, the output says that my system can't create more than around 600 threads. I need to create more threads, and fix my system misconfiguration.

Here are a few informations about my dedicated server:

de801:/# uname -a
Linux de801.ispfr.net 2.6.18-028stab085.5 #1 SMP Thu Apr 14 15:06:33 MSD 2011 x86_64 GNU/Linux
de801:/# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
de801:/# ldd $(which java)
        linux-vdso.so.1 =>  (0x00007fffbc3fd000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002af013225000)
        libjli.so => /usr/lib/jvm/java-6-sun- (0x00002af013441000)
        libdl.so.2 => /lib/libdl.so.2 (0x00002af01354b000)
        libc.so.6 => /lib/libc.so.6 (0x00002af013750000)
        /lib64/ld-linux-x86-64.so.2 (0x00002af013008000)
de801:/# cat /proc/sys/kernel/threads-max
de801:/# 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) 794624
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 10240
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 128
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Here is the output of the C program

de801:/test# ./thread-limit
Creating threads ...
Address of c = 1061520 KB
Address of c = 1081300 KB
Address of c = 1080904 KB
Address of c = 1081168 KB
Address of c = 1080508 KB
Address of c = 1080640 KB
Address of c = 1081432 KB
Address of c = 1081036 KB
Address of c = 1080772 KB
100 threads so far ...
200 threads so far ...
300 threads so far ...
400 threads so far ...
500 threads so far ...
600 threads so far ...
Failed with return code 12 creating thread 637.

Any ideas how to fix this please ?

share|improve this question

closed as too localized by JdeBP, slhck, Shiki, ChrisF, Sathya Nov 24 '11 at 13:54

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Did you try /etc/security/limits.conf? –  Not a Name Nov 21 '11 at 22:50
yes i did. it doesn't change anything, nor ulimit settings. –  Joel Nov 21 '11 at 22:51
This programming question relating to ENOMEM returns from pthread_create() was asked and answered on StackOverflow in August 2010. –  JdeBP Nov 21 '11 at 23:05
That is an out of memory error, so the issue isn't a thread count cap, but some other limit. Your stack size is small. You might want to think about migrating this to stackoverflow. –  Paul Nov 21 '11 at 23:06
@JdeBP Could you please provide a link to this answer ? –  Joel Nov 21 '11 at 23:06
show 5 more comments

2 Answers

Can you try changing the thread stack size, from the o/p of ulimit -a it shows it's "128".

try changing to 1024; ulimit -s 1024

Let me know the results.


share|improve this answer
I have tried every possible value for ulimit -s, going from 64K to 1024, 2048, more, and even unlimited. In any case, 600 threads is the limit on my system. –  Joel Nov 22 '11 at 4:56
what's the system memory n is this 32bit or 64 bit? –  maneeshshetty Nov 22 '11 at 5:01
64 bits with 2GB physical memory. –  Joel Nov 22 '11 at 5:37
RLIMIT_STACK does not bound the space consumed by thread stacks, though it does influence the default stack size of new threads. As such increasing it is not likely to help in this case. In some cases it could even make things worse. –  Richard Kettlewell Nov 22 '11 at 14:40
add comment
up vote -1 down vote accepted

Just got the following information: This is a limitation imposed by my host provider. This has nothing to do with programming, or linux.

share|improve this answer
That's drivel on its face. Of course it has something to do with programming and Linux. –  JdeBP Nov 22 '11 at 22:09
You are wrong. No it doesn't. It's a limitation artificially imposed by my server's host, who has customized debian's kernel. –  Joel Nov 23 '11 at 18:56
… which makes it to do with the Linux kernel and pthreads programming, kiddo. Please put the old brainbox in forward gear. This should be blatantly obvious, even to those who haven't twigged that this is one of a series of programming questions asked by you about a program that you are writing. –  JdeBP Nov 23 '11 at 23:08
Yes I am asking questions about a program that I am writing. That's what those exchange sites are for. And you could never write such a program with your slow brain, sorry for you. –  Joel Nov 23 '11 at 23:21
add comment

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