Java webstart max-heap-size导致JVM无法启动
我们在客户端使用 java webstart 来实现基于 java swing 的应用程序。最近,当单击 jnlp 链接时,我们遇到了一个奇怪的“无法启动 java 虚拟机”错误。
我们很快就发现了这一点,因为 jnlp 文件中的 max-heap-size 设置为 1024m,而大多数客户端 PC 只有 1 GB 物理内存。将 max-heap-size 设置回 512m 解决了问题。 目前,jnlp 文件中的相关行看起来像是
<j2se version="1.5+" initial-heap-size="100m" max-heap-size="512m"/>
我查看了 jnlp 规范,但找不到与“Java 虚拟机”问题相关的任何内容。理论上,最大堆大小不应该像初始堆大小那么重要。但我们的经验表明事实恰恰相反。
客户端环境:
Windows XP SP2(32位)、Internet Explorer 8.06、内存1G 注意 max-heap-size 设置为 1024m 可能会在具有 2G 内存的机器上导致相同的问题。
基本上,我在这里寻找的是一些关于为什么会发生这种情况的参考/规范/经验,以及除了增加物理内存大小之外是否有任何解决此问题的方法。
另一件事是,如果我们不指定 max-heap-size,是否会使用实际物理内存大小作为 max-heap-size,还是使用系统默认的内存大小?
We use java webstart on the client side for a java swing based aplication. Recently we have been experiencing a weird "Cannot start java Virtual machine " error when clicking in the jnlp link.
We soon find out its because the max-heap-size setting in the jnlp file was set to 1024m whereas most of the clients PC only have 1 gb physical memory. Set the max-heap-size back to 512m solved the problem.
Currently, the relevant line in the jnlp file looks like
<j2se version="1.5+" initial-heap-size="100m" max-heap-size="512m"/>
I looked into the jnlp spec, but cannot find anything related to the "Java Virtual machine" issue. In theory the max-heap-size should not matter as much as the initial-heap-size. But our experience suggested quite the contrary.
The client environment:
Windows XP SP2 ( 32bit ), Internet Explorer 8.06, Memory 1G
Note max-heap-size set to 1024m can cause the same problem on a machine with 2G ram.
Basically, what I am looking for here is some reference/spec/experience about why this is happening, and if there is any get-round for this issue besides increasing the physical memory size.
Another thing is that if we leave the max-heap-size unspecified, will the actual physical memory size be used as the max-heap-size, or a system-default one will be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该问题很可能是由于无法为您的 JVM 分配足够大的内存区域而引起的。出于实现原因,Java 对象堆必须分配在连续的虚拟地址中。
我注意到,在具有 2 Gb RAM 的 Win XP 机器上,该内存会在 1.5 GB 左右中断(当然,这取决于每台 PC 上运行的进程,所以 YMMV)。
查看以下帖子以获得一些解释:
Windows XP 上的 Java 最大内存
为什么 Java 堆的最大大小是固定的?
It is likely that this problem is caused by the fact that a sufficiently large memory area could not be allocated to your JVM. The Java object heap has to be allocated in contiguous virtual addresses, for implementation reasons.
I noticed that on a Win XP box with 2 Gb RAM this breaks at around 1.5 GB (this off course varies depending on what processes are running on each PC, so YMMV).
Checkout the following posts for some explanations:
Java maximum memory on Windows XP
Why is the maximum size of the Java heap fixed?
我发现 Mac 版本的 javaws 并没有很好地遵守初始堆大小和最大堆大小。我最终用这样的东西替换了它们:
最后让它在具有更大堆大小的 Mac 上工作
I found that both the initial-heap-size and max-heap-size were not well respected by the Mac version of javaws. I ended up replacing them with something like this:
And finally got it working on Mac with the larger heap size