Unable to create JVM (> 1024M)

I am creating a simple Java file that prints something to system.out, compiles and runs 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 of memory and I have no idea why this won't work. The execution java -Xmx512m MyClass

works, but I want to know why 1GB will be denied.

+2


a source to share


2 answers


Start your default virtual machine with -Xms512m -Xmx1024m



The default settings are slightly lower for eclipse, which is a little memory-scared.

+1


a source


I ran into similar problems - for me the limit was somewhere around 768M RAM. Apparently the JVM is trying to get more memory and in some cases there are limits on how much RAM the application can get.



If you are using a 32-bit system, but you can use the 64-bit version, use the latter, it may help. On 64-bit systems, I have not encountered this error.

+1


a source







All Articles