關於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