tags:

views:

75

answers:

2

Hi,

I create a simple Java file which prints something on the system.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.

A: 

Run your default VM with -Xms512m -Xmx1024m

The default settings are a bit low for eclipse, which is a bit of a memory hog.

mikek
I ran it with both 1G and 512M and both dont work
Calm Storm
Ah, have you tried raising the size of permsize to 512m as well?
mikek
Actually, I am not able to launch any JVM (even a mvn clean install) they all give the same error. Is there any by step by step guide to debug this?
Calm Storm
Ah, do you happen to have a JAVA_OPTS system variable set? Is it possible that any fo the memory options are set too low, or without the 'M' (thus defaulting to k?)
mikek
@mikek The JAVA_OPTS is not set at all. I have no clue as to what could be wrong here, heck !
Calm Storm
How much virtual memory do you have lying around by the way? Maybe you should try increasing the page file?Also, have you tried running java with the -Xm* parameters specified in the command line?
mikek
A: 

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.

Zoltán Ujhelyi
If he's on a 32-bit system I don't think he'll be able to use any 64 bit applications =)
mikek
Thats right. But I had similar problems without any solution in 32 bit systems. So if he could try it using a 64 bit system at least it can be tested.
Zoltán Ujhelyi