1

I am running jvm 1.8.0_65 and using Groovy to load classes dynamically, the Groovy version is 2.4.7. I turned on class unloading by adding "-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+TraceClassUnloading -Dgroovy.use.classvalue=true". But the classes loaded by Groovy won't unload on GC. I also loaded native Java classes in the same application, and these classes got unloaded as expected when garbage collected.

I analyzed the heap dump by MAT, and could not find any references to GC root that is not a weak reference, here are some screen shots: enter image description here The Class's path to GC Roots excluding weak/soft references

enter image description here The classloader's path to GC Roots excluding weak/soft references

enter image description here Things referencing the classloader.

So I really don't know what's stopping the JVM from unloading these classes. Any help is greatly appreciated!

HarryLv
  • 389
  • 2
  • 4
  • 7
  • Possible duplicate of [Why can a class not be unloaded without unloading the classloader?](https://stackoverflow.com/questions/2551276/why-can-a-class-not-be-unloaded-without-unloading-the-classloader) – the8472 Aug 05 '17 at 11:54
  • Are you using scripts ? – Nicholas Aug 06 '17 at 00:55

0 Answers0