<div dir="ltr">Hi Mikael, <div><br></div><div>Does this also happen if the Explicit GC is STW?</div><div>I have been reported that it also happens in STW Explicit GC.</div><div>Much rarely though.</div><div><br></div><div>
Jungwoo</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 11:43 PM, Mikael Gerdin <span dir="ltr"><<a href="mailto:mikael.gerdin@oracle.com" target="_blank">mikael.gerdin@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div><div class="h5"><br>
<br>
On 08/15/2013 02:37 AM, Jungwoo Ha wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Is ExplicitGCInvokesConcurrentAnd<u></u>UnloadsClasses guaranteed to unload all<br>
unused classes?<br>
We installed weak reference on the class objects to see none of the<br>
class objects are leaked.<br>
When using STW Explict GC all of the unused classes are unloaded,<br>
but when using above flag, only some are get unloaded.<br>
I double-checked the GC log and waited until the concurrent GC to finish<br>
its job.<br>
Is this an expected behavior or a bug?<br>
BTW, The leak detecting code using weak reference is used for a long time,<br>
which I think is quite stable.<br>
Any comments are appreciated!<br>
</blockquote>
<br></div></div>
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.<br>

<br>
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.<br>
<br>
/Mikael<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
Jungwoo Ha<br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>