Search code examples
javatomcatgarbage-collection

How the sun.reflect.GeneratedSerializationConstructorAccessor class generated


In order to print the GC logs of a web application,Before the tomcat startup,add the following parameters:

-Xms256m 
-Xmx512m 
-XX:PermSize=128M 
-XX:MaxPermSize=512M
-Xloggc:D:/TomcatGc.log

However, the following information is printed on the Terminal continuously.

[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor339]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor336]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor341]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor342]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor340]

My questions are:

  1. Why are these classes generated? I'd like to understand this concept, but can't find any information about it.

  2. How can I prevent the GC unloading them?


Solution

  • this is because (may be you are using reflection in your application) heap is running out of space and GC is trying to free some memory by unloading unused objects, that is why you see Unloading class sun.reflect.GeneratedSerializationConstructorAccessor

    More info --> http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2006-11/msg00122.html