PS Old Gen memory in Heap Memory Usage: GC settings for Java Out Of Memory Exception

amitsalyan picture amitsalyan · Sep 13, 2014 · Viewed 43.2k times · Source

enter image description here

Below are my JVM settings:

 JAVA_OPTS=-server -Xms2G -Xmx2G -XX:MaxPermSize=512M -Dsun.rmi.dgc.client.gcInterval=1200000 -Dsun.rmi.dgc.server.gcInterval=1200000 -XX:+UseParallelOldGC -XX:ParallelGCThreads=2 -XX:+UseCompressedOops  -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jbos88,server=y,suspend=n

Problem: Total Heap Memory: 2GB Old Gen: 1.4GB (2/3 of Heap) New Gen: 600MB(1/3 of Heap)

The Old Gen grows in memory beyond 70% 0f its allocated size and never is subjected to GC even at 100% i.e 1.4GB. One can see the graph below it peaks and never is GC, the drop in memory is when it was forced to GC from the JConsole. This problem is eventually bringing the web server down.

Anything that i am missing or wrongly setting the JVM?

Thanks for the help in advance.

Updating my Question:

After heap analysis it appears like Stateful session bean is the prime suspect: enter image description here We have stateful session beans that hold the persistence logic assisted by Hibernate.

Answer

David Limkys picture David Limkys · Sep 13, 2014

The GC will be called eventually, the old gen is almost never called (because it is extremely slow). The GC does run but it will only run on the new gen and survivor gen at first, it has a completely different algorithm for cleaning the old gen which is slower then new/survivor gens.

Those numbers are really high, the oldgen should never reach sum a high number compared to the newgen. My guess is that you have a memory leak.

I can only guess your program is dealing with big files, you are probably saving references to them for too long.