Java heap size: error when setting it too large

10,145

The likely case is that while your operating system is 64-bit, your JVM is not. Opening a command line and typing java -version will give you the verbose version information, which should indicate whether your installed JVM is a 32 or 64-bit build.

A 64-bit JVM should have no problem with the higher memory limits.

Share:
10,145
Yufei
Author by

Yufei

Updated on June 04, 2022

Comments

  • Yufei
    Yufei almost 2 years

    I have a program that fundamentally requires a lot of memory. However, for some reason java gives me an error when I try to set the max heap space above 1.5GB. That is, running

    java -Xmx1582m [my program]
    

    is okay, but

    java -Xmx1583m [my program]
    

    gives the error

    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    

    I got the same error in both Windows command line and Eclipse.

    Here are my system configurations:

    Windows 7 (64-bit)

    Intel Core 2 Quad CPU

    Installed RAM: 8.00 GB

    Java version 1.6.0

    It is weird that I can only set 1.5GB memory even though I'm running 64-bit OS with 8 GB RAM. Is there a way to work around this?