http://www.ibm.com/developerworks/cn/linux/l-cn-ulimit/linux
https://my.vertica.com/docs/5.0/HTML/Master/16468.htmspa
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited線程
能夠看到stack size是8M, 400個線程就須要8*400=3200M,虛擬內存不夠用。htm
解決辦法有兩種:ip
1.使用ulimit -s 1024*1024命令,將線程棧大小臨時設置成1M,通過試驗能同時建立2000個線程了。內存
2.使用pthread_attr_setstacksize在程序中改變線程棧大小。get