安卓java vm堆栈大小,如何确定Hotspot VM默认线程堆栈大小

在Windows上运行Java时,通过命令行选项`-Xss`可以设置线程堆栈大小。如果不指定该选项,Java虚拟机将使用默认值。默认值可以通过检查.exe文件头来获取,例如使用Cygwin的`objdump`工具或Microsoft Visual Studio的`dumpbin`实用程序。对于Java 7 64位,默认堆栈大小为1MB,32位版本则为320KB。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值