关于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


// 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,就是使用“系统默认值”。
可参考大神门的笔记:
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM