简体   繁体   English

无法设置大于 1568 的 Java 堆大小

[英]Unable to set Java heap size larger than 1568

I am running a server with the following attributes:我正在运行具有以下属性的服务器:

Windows Server 2008 R2 Standard - 64bit 4gb RAM Windows Server 2008 R2 标准版 - 64 位 4GB RAM

I am trying to set the heap size to 3gb for an application.我正在尝试将应用程序的堆大小设置为 3gb。 I am using the flags -Xmx3G -Xms3G.我正在使用标志 -Xmx3G -Xms3G。 Running with the flags results in the following error:使用标志运行会导致以下错误:

Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. VM 初始化期间发生错误 无法为对象堆保留足够的空间 无法创建 Java 虚拟机。

I have been playing with the setting to see what my ceiling is and found that 1568 is my ceiling.我一直在玩这个设置,看看我的天花板是多少,发现 1568 是我的天花板。 What am I missing?我错过了什么?

How much physical memory is available on your system (out of the original 4 GB)?您的系统上有多少物理内存可用(在原始 4 GB 之外)? It sounds like your system doesn't have 3GB of physical memory available when the vm starts up.听起来您的系统在 vm 启动时没有 3GB 的物理内存可用。

Remember that the JVM needs more memory than is allocated to the heap -- there are other data structures as well (thread stacks, etc) that also need memory.请记住,JVM 需要的内存多于分配给堆的内存——还有其他数据结构(线程堆栈等)也需要内存。 So the settings you are providing attempt to use more than 3GB of memory.因此,您提供的设置尝试使用超过 3GB 的内存。

Also, are you using a 64-bit jvm?另外,您使用的是 64 位 jvm 吗? The practical limit for heap size on a 32-bit vm is 1.4 to 1.6 gigabytes according to this document .根据本文档, 32 位虚拟机上堆大小的实际限制为 1.4 到 1.6 GB。

Java requires continuous virtual memory on startup. Java 在启动时需要连续的虚拟内存。 On windows, 32-bit application run in an 32-bit emulated environment so you don't get much more continuous memory than you would in a 32-bit OS.在 Windows 上,32 位应用程序在 32 位模拟环境中运行,因此与在 32 位操作系统中相比,您不会获得更多的连续内存。 cf on Solaris you get over 3 GB virtual memory for 32-bit Java. cf 在 Solaris 上,您会为 32 位 Java 获得超过 3 GB 的虚拟内存。

I suggest you use the 64-bit version of Java as this will make use of all the memory you have.我建议您使用 64 位版本的 Java,因为这将使用您拥有的所有内存。 You still need to have free memory but the larger address space doesn't suffer from fragmentation.您仍然需要有空闲内存,但更大的地址空间不会受到碎片的影响。

BTW: The heap space is only part of the memory used, you need memory for shared libraries, direct memory, GUI components etc.顺便说一句:堆空间只是所使用内存的一部分,您需要共享库、直接内存、GUI 组件等的内存。

It seems you don't have 3G of physical mememory available.看来您没有可用的 3G 物理内存。 Here is an interesting article on Java heap size settings errors.这是一篇关于 Java 堆大小设置错误的有趣文章。 Java heap size setting errors Java 堆大小设置错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM