views:

237

answers:

2

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?

+3  A: 

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.

Tim Stone
Ah, it seems that installing the 64-bit JDK works! Problem solved! Thanks :)
Yufei
Glad to hear it. Also, I hadn't realized that the 32-bit JVM doesn't mention it's 32-bit with `-version` (the 64-bit version actually says it's 64-bit), sorry about that!
Tim Stone
A: 

For heap space is used

-XX:MaxPermSize=64m
Daniel Moura
Could you elaborate? Runningjava -XX:MaxPermSize=64m -Xmx1583m [my program]still gives the same error.
Yufei