Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not reserve enough space for object heap

I am getting the following exception repeatedly each time I try to run the program.

Error occurred during initialization of VM

Could not reserve enough space for object heap

Could not create the Java virtual machine.

I tried to increase my virtual memory (page size) and RAM size, but to no avail.

How can I eliminate this error?

like image 370
Narendra Avatar asked Dec 09 '10 17:12

Narendra


People also ask

How do you reserve enough space for an object heap?

To fix the error "Could not reserve enough space for object heap", add the options "-Xmx<size>m" to set the maximum size for the object heap memory allocation. This must be set large enough to accommodate loading your application into memory, but smaller than your requested total memory allocation by 2GB.

Could not reserve enough space for object heap Error occurred during initialization of VM?

“Could not reserve enough space for object heap” is a specific JVM error that is raised when Java process cannot create the virtual machine due to memory constraints encountered on the running system: java -Xms4G -Xmx4G -jar HelloWorld.

What is the maximum heap size of 32-bit and 64 bit JVM?

So the theoretical limit for maximum heap size on 32 bit JVM is 4GB and for 64 bit JVM it's 2^64.


2 Answers

Run the JVM with -XX:MaxHeapSize=512m (or any big number as you need) (or -Xmx512m for short)

like image 172
Bozho Avatar answered Oct 24 '22 11:10

Bozho


This can also be caused by setting something too large on a 32-bit HotSpot vm, for example:

-Xms1536m -Xmx1536m 

where this might/would work:

-Xms1336m -Xmx1336m 
like image 40
djangofan Avatar answered Oct 24 '22 13:10

djangofan