0

I am running a Tomcat site(with an NGinx front end) that seems to be randomly running out of memory even though the max heap size is pretty large. My question is is it possible for the JVM to get an OutOfMemory error even if the heap size is significantly less than -Xmx? For instance, here is a snapshot I took just 15 seconds before an OutOfMemory error:

Tue Dec 18 23:13:28 JST 2012 Free memory: 162.31 MB Total memory: 727.75 MB Max memory: 3808.00 MB

I guess theoretically it's possible that my code generated 3 gigs worth of objects in 15 seconds, but I highly doubt it. It seems like the JVM was unable to grow the heap even though it theoretically had room....Is it possible that other processes started using memory to the point that the JVM could not grow? I am running 64-bit Oracle Hotspot on a 64 bit vm running CentOS 5 with 6 gigs of ram.

0

In Java there are many different pools of memory, thus eventhough you have enough heap size, you can still run out of memory. Here is an extract of a couple of other settings I have used at other java sites to experiment on your own with. I suggest that you consult the Java documentation also.

 .
 .
 .
 export JAVA_OPTS=" -XX:PermSize=32m -XX:MaxPermSize=512m ${JAVA_OPTS}"
 export JAVA_OPTS=" -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=8 ${JAVA_OPTS}"
 .
 .
 .
0

The relevant part of what you posted is:

Free memory: 162.31 MB

Your code probably did generate 162 MB worth of objects in 15 seconds.

Also, you say that you have an “OutOfMemoryError” but don’t list Insufficient Heap Space as the actual reason you had it, so yes, it is very possible that other processes used memory before the JVM could get it.

You probably already solved this problem, but for the future generations who may stumble on this question, you may want to specify what your JVM settings are in the question. It’s possible that too much memory was reserved for heap, but not enough for other parts of the JVM or other server processes, but we’d just be guessing without that information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.