ExplicitGCInvokesConcurrentAndUnloadsClasses leaks PermGen

Mikael Gerdin mikael.gerdin at oracle.com
Tue Aug 27 00:47:33 PDT 2013


Jungwoo,

On 2013-08-27 08:40, Jungwoo Ha wrote:
> Hi Mikael,
>
> Does the implicit reference you mentioned should show up in the heap dump?
> My collaborator checked the heap dump, and he didn't find any pointers
> to the older classloader other than the weak ref.

I'm not 100% sure that heap dumps can be trusted to correctly represent 
all the references that the GCs follow, especially when it comes to what 
keeps Classes alive.

/Mikael

>
> Jungwoo
>
>
> On Mon, Aug 26, 2013 at 10:35 PM, Mikael Gerdin
> <mikael.gerdin at oracle.com <mailto:mikael.gerdin at oracle.com>> wrote:
>
>     Hi Jungwoo,
>
>     The situation I described only affects concurrent collections with CMS.
>     If the explicit GC is STW (and thereby recorded as a Full GC in the
>     log) then you should not be seeing any issues.
>
>     Please make sure that you don't leak classes as it is very easy to
>     miss due to the implicit reference from Java
>     object->Class->ClassLoader.
>
>     /Mikael
>
>
>     On 26 August 2013 23:26:12 Jungwoo Ha __ wrote:
>
>>     Hi Mikael,
>>
>>     Does this also happen if the Explicit GC is STW?
>>     I have been reported that it also happens in STW Explicit GC.
>>     Much rarely though.
>>
>>     Jungwoo
>>
>>
>>     On Wed, Aug 14, 2013 at 11:43 PM, Mikael Gerdin
>>     <mikael.gerdin at oracle.com <mailto:mikael.gerdin at oracle.com>> wrote:
>>
>>         Hi,
>>
>>
>>         On 08/15/2013 02:37 AM, Jungwoo Ha wrote:
>>
>>             Hi,
>>
>>             Is ExplicitGCInvokesConcurrentAnd__UnloadsClasses
>>             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.
>>
>>         /Mikael
>>
>>
>>             Thanks,
>>             Jungwoo Ha
>>
>>
>>
>


More information about the hotspot-gc-dev mailing list