gpt4 book ai didi

java - 无法在堆大小较大的 64 位 Windows 7 中运行 64 位 JVM

转载 作者:可可西里 更新时间:2023-11-01 12:41:32 24 4
gpt4 key购买 nike

这是 64 位 Windows 7 Enterprise 和 64 位 Java 7:

java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

这发生在使用 C:\Windows\SystemWOW64\cmd.exe(我错误地认为是 64 位版本)的 shell 中 C:\Windows\System32\cmd.exe(我刚刚发现,由 Pulsar 提供,尽管有路径名称,但它是一个 64 位应用程序)。

程序本身很简单:

public class Trivial
{
public static void main(String[] args) {
System.out.println("total = " + toMB(Runtime.getRuntime().totalMemory()));
System.out.println("max = " + toMB(Runtime.getRuntime().maxMemory()));
}

private static long toMB(long bytes) {
return bytes / (1024L * 1024L);
}
}

我只是在玩弄不同的 -Xmx-Xms 参数,看看会发生什么。尽管在 64 位 Windows 上使用 64 位 Java,我可以使用几乎任何我想要的最大大小和初始堆,但事实并非如此。

java -Xmx16G -Xms2G Trivial(例如)工作正常。但是,java -Xmx16G -Xms4G Trivial 给我:

Error occurred during initialization of VM
Could not reserve enough space for object heap

更奇怪(对我来说),java -Xmx16G -Xms3G Trivial 给出了不同的错误:

Error occurred during initialization of VM
Unable to allocate tables for parallel garbage collection for the requested heap size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

尝试拆分 2G3G 之间的差异,看看是否有特定大小发生这种情况我尝试了 java -Xmx16G -Xms2900M Trivial 并且有效。然后我尝试了 -Xms2960M 并且成功了。使用 -Xms2970m JVM 崩溃了:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1048576 bytes for E in C:\jdk7u2_64p\jdk7u4\hotspot\src\share\vm\utilities/taskqueue.hpp
# An error report file with more information is saved as:
# C:\Users\QuantumMechanic\Temp\hs_err_pid10780.log

这一直持续到 -Xms2995M 时,它切换回“无法为并行垃圾收集分配表”消息并随着 -Xms 的进一步增加而坚持下去。

可能发生了什么?从 cmd.exe(即使是 64 位的)启动某些东西是否会施加一些进程大小限制? Windows(或 JVM)是​​否需要一个巨大的内存块? (但是为什么会有不同的消息)?还有别的吗?

最佳答案

SysWoW64 指的是 32 位 Windows on Windows 64。简化:32 位 Windows 在 64 位 Windows 上运行)。

因此您明确要求在 32 位 cmd shell 中运行。

请看:

http://en.wikipedia.org/wiki/WoW64

关于java - 无法在堆大小较大的 64 位 Windows 7 中运行 64 位 JVM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10889081/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com