How to determine Hotspot VM default thread stack size

99封情书 提交于 2019-12-10 14:53:38

问题


If I run java from the command line on my windows box like this:

"C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -XshowSettings:all -Xss=1m -Xmx256m

I see this output:

VM settings:
Stack Size: 1.00M
Max. Heap Size: 256.00M
Ergonomics Machine Class: client
Using VM: Java HotSpot(TM) Client VM

The important part for me is "Stack Size: 1.00M", which is what I set it to be via the command line option "-Xss1m". But if I remove this option and let the VM run with the default stack size I get this output:

VM settings:
Max. Heap Size: 256.00M
Ergonomics Machine Class: client
Using VM: Java HotSpot(TM) Client VM

Notice it no longer displays the "Stack Size" anymore. I was hoping I would see the default size if I didn't specify a custom "-Xss" value. Is there any way to determine the default thread stack size?


回答1:


The default stack size of Windows application is specified in .exe file header.
You can find it out using Cygwin objdump tool or with Microsoft Visual Studio dumpbin utility:

C:\Program Files\Java\jdk1.7.0_51\bin> objdump -p java.exe | grep Stack
SizeOfStackReserve      0000000000100000
SizeOfStackCommit       0000000000001000

C:\Program Files\Java\jdk1.7.0_51\bin> dumpbin.exe /headers java.exe | grep stack
      100000 size of stack reserve
        1000 size of stack commit

As we can see, Java 7 x64 default stack size in 0x100000 (1 MB).
For x86 version, the default stack size is 0x50000 (320 KB):

C:\Program Files (x86)\Java\jre7\bin>objdump -p java.exe | grep Stack
SizeOfStackReserve      00050000
SizeOfStackCommit       00001000


来源:https://stackoverflow.com/questions/23552296/how-to-determine-hotspot-vm-default-thread-stack-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!