Java Startup Memory Issue Solved

Towards the end of every week, my version of WebLogic stops cooperating and shows a memory error when I try to start it.

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

It doesn’t make sense because I have plenty of free memory available. A reboot solves the problem – a popular enough solution for Windows. Still, rebooting to fix something that should be working leaves me with a bad feeling. The OS has enough memory, and I am on a 64-bit Windows 7 machine so this should not be an issue.

windows7 task manager performance tab

Here is what the WebLogic startup command outputs:

$ startWebLogic.cmd
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=48m -XX:MaxPermSize=128m
WLS Start Mode=Development
....snipped....
starting weblogic with Java version:
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b50)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode)
Starting WLS with line:
....snipped....
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

 

In researching the problem, it turned out my version of WebLogic was pointed at a 32-bit version of Java… The problem here is, the 32-bit version of Java requires a contiguous block of memory. My machine had been running for some time. Even though I had ample free memory, there was not a single block of free memory large enough to accommodate the JVM. There is no way I could find to ‘defrag’ RAM in Windows 7 other than to reboot, which I’d like to avoid.

 

The solution is to point WebLogic at a 64-bit JDK. This can be done by editing {weblogic install}\user_projects\{your_domain}\bin\setDomainEnv.cmd. My solution was to add this around line 64:

set JAVA_HOME=C:\software\jdk1.6.0_27

 

Now, we get an explicit 64-bit notice on startup:

starting weblogic with Java version:
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)

 

Look for Java HotSpot(TM) 64-Bit Server VM to tell a 64-bit version of java has been used. This can also be checked by running “$ java –version”.

Goodbye 32-bit Java.

This entry was posted in Application Development, Sys Admin. Bookmark the permalink.

Comments are closed.