Usually for CMS I will see the following stdout
[Unloading class sun.reflect.GeneratedMethodAccessorXXX] [Unloading class sun.reflect.GeneratedConstructorAccessorXXXX] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessorXXX] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessorXXX] [Unloading class sun.reflect.GeneratedSerializationConstructorAccessorXXX]
but I notice the following in them too
[Unloading class Customer_datasetXXXXX] – 280+ occurrence in log
[Unloading class Item_XXXXXX] – 220+ occurrence in log
[Unloading class Receipt_XXXXX] – 30+ occurrence in log
[Unloading class Foo_XXXXX] – 190 occurrence in log
*XXXXX are just random numbers.
May I know what will most likely cause the above and is it normal?
I don't understand why are there that many occurrence for class objects? A class is a template and an object is an instance of a class. So why do I have so many occurrence of Foo class being unloaded?
This is a standard behavior of GC not related to CMS algorithm in specific. The GC is unloading class objects that are no longer in use.
While the first log snippet shows that class objects related to reflection implementation were unloaded, the second log snippet is referring to regular classes from the running application. GC does treat both types of class objects the same.
Please, check your JVM version and then see if you want to disable/enable class unloading by using
-XX:+CMSClassUnloadingEnabled
(or-XX:-CMSClassUnloadingEnabled
) during CMS:More info about the ClassUnloading in general: