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:
Why are these classes generated? I'd like to understand this concept, but can't find any information about it.
How can I prevent the GC unloading them?
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
Different type of accessors
The method accessor and constructor accessors are either native or generated. This means that either we use NativeMethodAccessorImpl or GeneratedMethodAccessor for Methods and NativeConstructorAccessorImpl and GeneratedConstructorAccessor for Constructors. The accessor would be a native or generated and is controlled and decided by two system properties:
When the sun.reflect.noInflation is set to true then the accessor used will always be generated and there is no meaning for the system property sun.reflect.inflationThreshold. When the sun.reflect.noInflation is false and the sun.reflect.inflationThreshold is set to 15 (thats the default behavior if not specified) then it means that for the first 15 accesses to the constructor (or methods), a native generator will be used and thereafter a generated accessor will be supplied (from ReflectionFactory) for use.
The Native accessor uses native calls to access information, whereas the generated accessor is all byte code and hence very fast. On the other hand generated accessor needs time to instantiate and load (basically inflates and hence the system properties controlling it has names including 'inflation' word).
More details can be found at the original blog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With