I have a web app built on top of SpringMVC 3.2 and running on Tomcat. I use the VisualVM to monitor the permgen space and found it increase constantly:
I take three heap dump and run the "ClassLoader Loaded Classes Histo" analysis and found these results:
the 9:44pm dump:
loader:org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader#1,
count:3285
the 9:55pm dump:
loader:org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader#1,
count:3286
the 7:40am dump:
loader:org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader#1,
count:3855
My app is very quite during the period. However it looks the number of classes been loaded are increasing constantly. I want to understand which classes are newly loaded across these heap dump. Running the "ClassLoader Loaded Classes" doesn't give me too much information as I am buried into these kind of information:
Anyone has experience on analysing this kind of issue?
Update with the JVM info
JVM: Java HotSpot(TM) 64-Bit Server VM (20.45-b01, mixed mode)
Java: version 1.6.0_45, vendor Sun Microsystems Inc.
JVM args:
-Dvisualvm.id=4226015013703
-Xdebug
-Xrunjdwp:transport=dt_shmem,address=javadebug,suspend=y,server=n
-Dvisualvm.id=4214057282541
-Denv=dev-no-mas
-Dorg.slf4j.simpleLogger.defaultLogLevel=debug
-Dssgateway.disabled=true
-Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=1299
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=127.0.0.1
-Djava.util.logging.config.file=C:\Users\luog.IKARI\.IntelliJIdea13\system\tomcat\Unnamed_rythm_2\conf\logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs=C:\l\j\apache-tomcat-6.0.29\endorsed
-Dcatalina.base=C:\Users\luog.IKARI\.IntelliJIdea13\system\tomcat\Unnamed_rythm_2
-Dcatalina.home=C:\l\j\apache-tomcat-6.0.29
-Djava.io.tmpdir=C:\l\j\apache-tomcat-6.0.29\temp
The general issue is that every class hold reference to the Class definition and every class loader that created him, And every classloader hold a reference to all the classes he is created. So when the garbage collector moving on all the objects, because they have always reference they keep growing.. and the GC not release them. In the example they use :
${JAVA_HOME}/bin/jvisualvm
Which is tool that can help you, The Solution is long and the link provide help with images.. This tool can help you find the classloader that cause the leak(Class loader is for every application under the server in order to ley several applications run toghther under the same server)
Than you will go find the problem class.. Once you will know what is causing the problem you will be able to cure it..
This is link that will exaplain why this is happening and how to deal:
cdivilly.wordpress.com/2012/04/23/permgen-memory-leak/
You can read this great presentation .. From page 11 you can see how you can identify the leaks and the solutions.. Very Very useful http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf
Hope that more helpful