Java 7: should users be aware of changes in heap memory handling

heapspacejavamemorytomcat7

After installing the latest Java 7 Development Kit (Java SE 7u11) on my Windows 7 Professional 32bit PC with 4Gb RAM, I noticed I can't allocate much memory for Tomcat.

Whereas these memory settings worked for Java Development Kit 6u38:

set JAVA_OPTS=-server -Xms978m -Xmx978m -XX:MaxPermSize=512m

…when run with jdk7, these settings cause the Tomcat launcher to exit with following error message:

Error occurred during initialization of VM

Could not reserve enough space for object heap

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

I tried lowering the Xms and Xmx settings, and apparently, it won't work with more than 512m:

set JAVA_OPTS=-server -Xms512m -Xmx512m -XX:MaxPermSize=512m

Yet, systeminfo |find "Available Physical Memory" tells me that I have 1200mb available memory.

Has anything changed w.r.t. memory management of Java 7, and does this mean that Java 7 can only work with lower amounts of memory?

Thanks for any advice,

Ron

Best Answer

Two information that could help you, calculation the memory correctly:

  1. a 32 bit OS can't use more then 3GB RAM, even if there is more installed
  2. Although the memory is allocated for Java, it is "free" at the system info as long as java is not actively using it

If you also have any other java process running (e.g. eclipse?), you won't see the allocated memory of these processes, too.

Related Topic