我的操作系统信息如下:
Linux 3.1.10-1.16-default #1 SMP Wed Jun 27 05:21:40 UTC 2012 (d016078) x86_64 x86_64 x86_64 GNU/Linux
我的JDK信息是:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (suse-6.2-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
但是如果我使用超过 1GB 的堆栈,
java -Xss2g -Xmx100g Test
我懂了:
Error occurred during initialization of VM
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.lang.ref.Reference.<clinit>(Reference.java:162)
那么,我怎么能使用超过 1GB 的堆栈呢?
使用“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) 1291902
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) 1291902
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
由此看来,堆栈大小限制似乎只有 8MB。但它成功了 1GB。