“Error occurred during initialization of VM; Could not reserve enough space for object heap” using

First of all, I have a box with 8gb of ram, so I doubt total memory is the issue. This application is running fine on machines with 6gb or less.

I am trying to reserve 3GB of space using -Xmx3G under "VM Arguments" in Run Configurations in Eclipse.

Every time I try to reserve more than 1500mb, I get this error: “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G

What is going on here?


难道你在那台机器上使用32位的jvm?


This is actually not an Eclipse-specific issue; it's a general Java-on-Windows issue. It's because of how the JVM allocates memory on Windows; it insists on allocating a contiguous chunk of memory, which often Windows can't provide, even if there are enough separate chunks to satisfy the allocation request. There are utilities that will try to help Windows "defrag" its memory, which would, in theory, help this situation; but I've not really tried them in earnest so can't speak to their effectiveness. One thing that I've heard sometimes that might help is to reboot Windows and, before starting any other apps, launch the Java app that needs the big chunk of memory. If you're lucky, Windows won't have fragmented its memory space yet and Java will get the contiguous block that is asks for.

Somewhere out on the interwebs there are more technical explanations and analyses of this issue, but I don't have any references handy.

I did find this, though, which looks helpful: https://stackoverflow.com/a/497757/639520


Here is how to fix it: Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System

Variables->New:
Variable name: _JAVA_OPTIONS   
Variable value: -Xmx512M

Variable name: Path  
Variable value: ;C:Program FilesJavajre6bin;F:JDKbin;  

Change this to your appropriate path .

链接地址: http://www.djcxy.com/p/82902.html

上一篇: 在jenkins中无法为对象堆错误预留足够的空间

下一篇: “VM初始化期间发生错误; 无法为对象堆预留足够的空间