ExplicitGCInvokesConcurrentAndUnloadsClasses leaks PermGen
mikael.gerdin at oracle.com
Wed Aug 14 23:43:35 PDT 2013
On 08/15/2013 02:37 AM, Jungwoo Ha wrote:
> Is ExplicitGCInvokesConcurrentAndUnloadsClasses guaranteed to unload all
> unused classes?
> We installed weak reference on the class objects to see none of the
> class objects are leaked.
> When using STW Explict GC all of the unused classes are unloaded,
> but when using above flag, only some are get unloaded.
> I double-checked the GC log and waited until the concurrent GC to finish
> its job.
> Is this an expected behavior or a bug?
> BTW, The leak detecting code using weak reference is used for a long time,
> which I think is quite stable.
> Any comments are appreciated!
A caveat with CMS and class unloading is that CMS treats all objects in
the young generation as strong roots. You need to make sure that you've
triggered enough young GCs so that your weak references are promoted out
of the young gen before triggering the explicit CMS cycle.
If you have a small test case you can try reducing the young gen size
and setting MaxTenuringThreshold=1 and see if all the classes get
unloaded as you expected.
> Jungwoo Ha
More information about the hotspot-gc-dev