如何确定Hotspot VM默认线程堆栈大小 [英] How to determine Hotspot VM default thread stack size
问题描述
如果我从Windows窗口的命令行运行Java,如下所示:
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
我看到以下输出:
VM settings:
Stack Size: 1.00M
Max. Heap Size: 256.00M
Ergonomics Machine Class: client
Using VM: Java HotSpot(TM) Client VM
对我来说重要的部分是堆栈大小:1.00M",这是我通过命令行选项"-Xss1m"设置的值.但是,如果删除此选项,并让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
注意,它不再显示堆栈大小".我希望如果不指定自定义"-Xss"值,则可以看到默认大小.有什么方法可以确定默认的线程堆栈大小?
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?
推荐答案
Windows应用程序的默认堆栈大小在.exe
文件头中指定.
您可以使用Cygwin objdump
工具或Microsoft Visual Studio dumpbin
实用工具找到它:
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
我们可以看到,Java 7 x64的默认堆栈大小为0x100000(1 MB).
对于x86版本,默认堆栈大小为0x50000(320 KB):
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
这篇关于如何确定Hotspot VM默认线程堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!