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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With