Friday, April 30, 2010

java.lang.OutOfMemoryError: PermGen space

First, http://blogs.sun.com/fkieviet/entry/classloader_leaks_the_dreaded_java
Then, http://blogs.sun.com/fkieviet/entry/how_to_fix_the_dreaded

http://community.eapps.com/showthread.php?153-Eliminate-PermGen-out-of-memory-errors-for-good! : It says use -XX:+CMSPermGenSweepingEnabled, -XX:+CMSClassUnloadingEnabled. But what if the classes are still being referred as discussed in the first two SUN blog posts.


http://java.dzone.com/articles/java-performance-tuning?page=0,1 : A generic article


http://stackoverflow.com/questions/88235/how-to-deal-with-java-lang-outofmemoryerror-permgen-space-error

http://forum.springsource.org/showthread.php?t=21383&highlight=cglib+cache : heated up arguments

http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/memleaks.html#gbyuu: Permgen issue with interned Strings

http://rajakannappan.blogspot.com/2010/01/outofmemoryerror-on-heapspace-permgen.html : Suggests using XX:+TraceClassLoading and -XX:+TraceClassUnloading , XX:+PrintGCDetails  , JVisualVM


http://www.samaxes.com/2007/10/classloader-leaks-and-permgen-space/ : Basically analyses the first two SUN blog posts and directs to following  useful posts.
1. http://blogs.sun.com/sundararajan/entry/jhat_s_javascript_interface : contains the oql function for histograms
3. http://mediacast.sun.com/users/Frank.Kieviet/media/JavaOne07-BOF9982-PermGen.pdf : awesome


JACKPOT- what worked for me
http://little418.com/2009/08/grails-configslurper-and-its-permgen-apatite.html : check the email chain too.
Basically I was parsing a config (thus creating new() ConfigSlurper ) inside a method of my service that's called multiple fixed no. of times (say X ) from my cron job. At each cron job run some fixed number of dynamically created classes were loaded X times(each time with some different ID that's used in the class name). When cron job finishes the objects are freed but the classes remian loaded.
Solution: Moved config parsing to the constructor of my service and made ConfigSlurper object as a class parameter(earlier it was a local method variable)

No comments:

Post a Comment