2

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?

Community
  • 1
  • 1
user4127
  • 2,397
  • 6
  • 21
  • 32

1 Answers1

2

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:

Community
  • 1
  • 1
Aleš
  • 8,896
  • 8
  • 62
  • 107
  • but 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? – user4127 Jan 22 '14 at 00:53
  • What does the suffix XXXX means, is that part static or does it change for each Foo occurrence? These may be classes that are dynamically generated and thus there may be many instances of Foo_. You will need to go into the source code and see where Foo_XXXX is being instantiated. – Aleš Jan 22 '14 at 01:01
  • they are random no. Care to give some example of dynamically generated vs normal instantiate ? – user4127 Jan 22 '14 at 01:06
  • An example of a code generated at runtime can be JSP, where Java code can be generated out of JSP template during the run time. Another example is the Proxy pattern, where many instances of `com.sun.proxy.$ProxyXX` class are generated, substitute "XX" by an integer. – Aleš Jan 22 '14 at 04:06
  • There probably can be also custom class factories creating classes at runtime, which may be your case. – Aleš Jan 22 '14 at 04:07