I create a simple Java file which prints something on the system开发者_JAVA技巧.out, compile and run it with the following,
public class MyClass {
public static void main(String[] args) {
System.out.println("MyClass here");
}
}
java -Xmx1024m MyClass
and I get
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I have 4GB memory and I have no idea at all why this would not work. Doing java -Xmx512m MyClass
works, but I want to know why 1GB will be denied.
Run your default VM with -Xms512m -Xmx1024m
The default settings are a bit low for eclipse, which is a bit of a memory hog.
I had experienced similar problems - for me the limit was somewhere near 768M of RAM. Apparently the JVM tries to obtain a larger amount of memory, and in some cases there are limits, how many RAM can an application obtain.
If you are using a 32 bit system, but are able to use a 64 bit, use the latter, it might help. On 64 bit systems I did not encounter this error.
精彩评论