How to Resolve Could not reserve enough space for object heap

  • by

Tried to execute a Java program like the following:

C:\Users\edchen>java -Xmx1500M -cp C:\ERPAPP\jarfiles\* ...
...
Error occurred during initialization of VM
Could not reserve enough space for 1536000KB object heap

C:\Users\edchen>
Could not reserve enough space for 1536000KB object heap

Could not reserve enough space for 1536000KB object heap

Could not reserve enough space for object heap means that JVM cannot reserve specified memory from OS at this moment. In this case, the heap size is 1500MB.

Solutions

Several ways may solve the error.

1. Lower Heap Size

C:\Users\edchen>java -Xmx750M -cp C:\ERPAPP\jarfiles\* ...

In the above, I cut a half of heap size from 1500M into 750M if the program accepts the value.

2. Close Unnecessary Programs

The action releases some memory from those closed programs and make more memory available for Java to reserve.

3. Restart OS

If there's no program can be release at this moment, you can restart the OS to provide a fresh environment for your Java program.

Leave a Reply

Your email address will not be published. Required fields are marked *