运行此程序时 线程limit.c 在我的专用debian服务器上,输出显示我的系统不能创建超过600个线程。我需要创建更多线程,并修复我的系统配置错误。
以下是有关我的专用服务器的一些信息:
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-1.6.0.26/jre/bin/../lib/amd64/jli/libjli.so (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
1589248
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
这是C程序的输出
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.
任何想法如何解决这个问题?
你有没有试过/etc/security/limits.conf?
—
Not a Name
是的,我做到了。它不会改变任何东西,也不会改变ulimit设置。
—
Joel
这个编程问题涉及到
—
JdeBP
ENOMEM
从...返回 pthread_create()
在2010年8月的StackOverflow上被问及并回答。
这是一个内存不足错误,因此问题不是线程计数上限,而是一些其他限制。你的堆栈大小很小。您可能想要考虑将其迁移到stackoverflow。
—
Paul
@JdeBP你能否提供这个答案的链接?
—
Joel