3

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?

Yufei Zhao
  • 1,053
  • 3
  • 9
  • 8
  • Are you using a the JRE for Windows or Windows x64? – Vineet Reynolds Aug 11 '10 at 15:29
  • Similar: http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os – Pops Aug 11 '10 at 15:30
  • I know you said you have 8GB of RAM, but the text of the error matches the "you're using a bigger heap than there is memory available" error. I think this may be a JVM limitation, but I'm still looking into it. – Pops Aug 11 '10 at 15:33
  • 1
    My java -version says: java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing) I can't tell whether this is 32- or 64-bit. – Yufei Zhao Aug 11 '10 at 15:42
  • check out [this question](http://stackoverflow.com/questions/2062020/how-can-i-tell-if-im-running-in-64-bit-jvm-or-32-bit-jvm) for the JVM info. – Pops Aug 11 '10 at 15:47

2 Answers2

5

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
  • 19,119
  • 6
  • 56
  • 66
  • Ah, it seems that installing the 64-bit JDK works! Problem solved! Thanks :) – Yufei Zhao Aug 11 '10 at 15:51
  • 1
    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 Aug 11 '10 at 15:56
-3

For heap space is used

-XX:MaxPermSize=64m
Daniel Moura
  • 7,816
  • 5
  • 35
  • 60
  • 1
    Could you elaborate? Running java -XX:MaxPermSize=64m -Xmx1583m [my program] still gives the same error. – Yufei Zhao Aug 11 '10 at 15:32
  • 1
    -1 `-XX:MaxPermSize` is for Permanent Generation. It's size is counted apart of the rest of the heap. – fglez Aug 21 '12 at 15:09