Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java heap size: error when setting it too large

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?

like image 226
Yufei Avatar asked Feb 24 '26 22:02

Yufei


1 Answers

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.

like image 119
Tim Stone Avatar answered Mar 01 '26 04:03

Tim Stone