1

Currently we are encountering an problem, our java application can run smoothly with JRE6, but for JRE7, it will report "Could not create the Java virtual machine" sometimes and failed to start program. we have "-Xmx1024m" option in the launch command line.

after searching in google, people suggest check the max heap size that can be requested in PC. then I tried below ones.

for JRE6,

C:\Users\joey>java -Xmx1214m -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode)

C:\Users\joey>java -Xmx1215m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

for JRE7,

D:\Program Files\Java\jre7\bin>java.exe -Xmx930m -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)

D:\Program Files\Java\jre7\bin>java.exe -Xmx931m -version
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.

And when i close most processes in PC and free memory to 2.5 GB, for JRE7, it will succeed with 1094m, like below.

D:\Program Files\Java\jre7\bin>java.exe -Xmx1094m -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)

D:\Program Files\Java\jre7\bin>java.exe -Xmx1095m -version
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.

It seems that the max heap size that JVM can request is related with system available memory size, does someone know the exact relationship?

Is there some way to enable tracing logs of JRE when creating JVM?

Thank you!

Regards, Joey

trincot
  • 317,000
  • 35
  • 244
  • 286
Joey Sun
  • 109
  • 3
  • 8

2 Answers2

0

I faced the same issue on various Windows OS flavous (Win7, Win2008R2) while having enough free RAM (3-5G), when switching from jre6_20 to jre7_51 (both 32 bit VMs)

Using vm args -Xmx1300m and -XX:MaxPermSize=256m on java 6 the VM is able to start. However, with java7 I had to lower down startup max memory (xmx with 100m or permgen with 100m) in order to be able to start VM.

The interesting part is this: if I restarted my box, the jvm 7 started with original vm args (-Xmx1300m and -XX:MaxPermSize=256m) so I suspect the root cause might be the OS with JVM combination.

I know that on Windows OSes - 32 bit VMs expect to have a single large chunk of memory, but cannot use the maximum process memory size will range from 1.4G to 1.6G (because of additional constraints)

Any troubleshooting pointers? Oracle does not provide any information in java7 release notes (or I could not spot those)

Community
  • 1
  • 1
Ovidiu Lupas
  • 185
  • 5
0

I have a similar problem Windows 7 64bit, no JAVA_HOME set nor in PATH This fails "C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -Xms32m -Xmx1024m -XX:MaxPermSize=256m -version

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.

This works "C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -Xms32m -Xmx512m -XX:MaxPermSize=256m -version

This also works (I can recompile or not, doesn't make a difference "C:\Program Files (x86)\Java\jdk1.6.0_45\bin\java.exe" -Xms32m -Xmx1024m -XX:MaxPermSize=256m -version

I tried turning off windows DEP, didnt make a difference http://windows.microsoft.com/en-us/windows-vista/data-execution-prevention-frequently-asked-questions

I twiddled with the Virtual Memory settings , changed from allowing Windows to Manage http://windows.microsoft.com/en-us/windows/change-virtual-memory-size#1TC=windows-7

I upped the Virual Memory in windows and it allowed it to work, sometimes...(with xmx1024)

Nothing else is consuming a lot of resources (memory, etc, I did have oracle database running locally, but shut it down)

"C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -Xms32m -Xmx1024m -XX:MaxPermSize=256m -version 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.

This works "C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -Xms32m -Xmx900m -XX:MaxPermSize=256m -version

This fails U:>"C:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe" -Xms32m -Xmx2024m -XX :MaxPermSize=256m -version 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.

New version , works even with letting Windows Managage the Virtual Memory and DEP turned on "C:\Program Files (x86)\Java\jdk1.7.0_65\bin\java.exe" -Xms32m -Xmx1024m -XX:MaxPermSize=256m -version