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

Could it be that you're using a 32-bit jvm on that machine?


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 Files\Java\jre6\bin;F:\JDK\bin;  

Change this to your appropriate path.


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


First the JRE of 32bits can't use more ~1.5Gb of ram. So if you want more, use a 64bits JRE.

Second, When a new JVM starts, this sum the -Xmx property of the all JVM that are running, and check if there is enough memory left on the system to run at their own -Xmx, if is not enough then the error occurs.