动态可扩展的JVM堆栈 [英] Dynamically expandable JVM stack

查看:245
本文介绍了动态可扩展的JVM堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JVM规范表示JVM堆栈可以是固定大小,也可以是动态可扩展的。

The JVM specification indicates the JVM stack can be either fixed size or dynamically expandable.

-Xss JVM选项允许设置固定大小,如果我没有设置这个选项是设置默认值(大约512-2048k),但是如何告诉JVM在需要时动态分配其堆栈?

The -Xss JVM option allow to set the fixed size and if I am right not setting this option is setting a default value (around 512-2048k), but how can tell the JVM to dynamically allocate its stack when needed?

如果我无法设置动态大小选项,设置一个大的-Xss值(假设20M)实际上为我的JVM中的每个线程分配了20MB的内存,还是动态分配的内存将限制为20MB?

If I cannot set a dynamical size option, will setting a large -Xss value (let's say 20M) actually allocate 20MB of memory for each thread in my JVM or is it dynamically allocated memory that will be limited to 20MB?

推荐答案

最大堆栈大小是分配给堆栈的虚拟地址空间的数量。内存仅根据需要提交到堆栈。

The maximum stack size is the amount of virtual address space that gets allocated to the stack. Memory is only committed to the stack as required.

请注意,在32位系统上,虚拟地址空间是一种相对稀缺的资源。每个进程的收益少于4GB(有时少)。考虑到这一点,20MB的堆栈会将线程数限制在75到175之间。

Note that on 32-bit systems, virtual address space is a relatively scarce resource. You get less (sometimes much less) than 4GB per process. With this in mind, a 20MB stack would limit the number of threads to anywhere between 75 and 175.

这篇关于动态可扩展的JVM堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆