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

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.


Even still having the main problem (memory leak) resolved, if you still want the old gen to be cleared in frequent small sized pauses, you may try setting

-XX:MaxGCPauseMillis=(time in millis)

and this is only applicable with Parallel Collector and when Adaptive Sizing Policy is on. By default Adaptive Sizing Policy is on, but, if you want to explicitly mention this you can use.

-XX:+UseAdaptiveSizePolicy

Or else you can switch to CMS collector where you can use

-XX:CMSInitiatingOccupancyFraction=(% value) 
-XX:+UseCMSInitiatingOccupancyOnly

Which is a more reliable way of collecting the old gen when it has reached a certain fraction of the the old gen.


enter image description hereThe stateful session beans were making the JVM run out of memory. Explicitly handling them using @Remove annotation resolved this issue.