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

标签 java windows memory-management 64-bit

这是 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/

相关文章:

java - 根据语言环境确定日期时间模式

java - 检查单词是否包含数字或特殊字符

java - 排序程序: What is the next step?

java - Jetty 通过多部分请求直接将文件上传到 FileInputStream

c++ - 将 GTKmm 添加到 CodeBlocks - Windows

windows - boot2docker vm 在重新启动时忘记更改

c - 为什么在执行 memcpy 时检测到堆栈粉碎?

C 内存分配器和严格的别名

python - 在 Python 中删除一个对象和对它的所有引用?

windows - Windows 10 上的 Linux 子系统位于 C : 以外的另一个驱动器上