Java – Could not reserve enough space for object heap

heapjavajvm

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?

Best Answer

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