关于Linux x64 Oracle JDK7u60 64-bit HotSpot VM 线程栈默认大小问题的整理
JVM线程的栈默认大小,oracle官网有简单描述:
In Java SE 6, the default on Sparc is 512k in the 32-bit VM, and 1024k in the 64-bit VM. On x86 Solaris/Linux it is 320k in the 32-bit VM and 1024k in the 64-bit VM.
On Windows, the default thread stack size is read from the binary (java.exe). As of Java SE 6, this value is 320k in the 32-bit VM and 1024k in the 64-bit VM.
You can reduce your stack size by running with the -Xss option. For example:
java -server -Xss64k
Note that on some versions of Windows, the OS may round up thread stack sizes using very coarse granularity. If the requested size is less than the default size by 1K or more,
the stack size is rounded up to the default; otherwise, the stack size is rounded up to a multiple of 1 MB.
64k is the least amount of stack space allowed per thread.
可参考:Frequently Asked Questions About the Java HotSpot VM
实际上:Linux x64 Oracle JDK7u60 64-bit HotSpot VM 下,普通Java线程的默认栈大小怎样都是1MB。
define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system defaul
http://hg.openjdk.java.net/jdk7u/jdk7u/hotspot/file/2cd3690f644c/src/os_cpu/linux_x86/vm/os_linux_x86.cpp#l654 :
// return default stack size for thr_type
size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack)
#ifdef AMD64
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
#else
size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
#endif // AMD64
return s;
}
不显式设置-Xss或-XX:ThreadStackSize时,或者把-Xss或者-XX:ThreadStackSize设为0,就是使用“系统默认值”。
可参考大神门的笔记:
posted on 2016-12-21 23:12 jessezeng 阅读(2044) 评论(0) 编辑 收藏 举报