<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Jungwoo,<br>
    <br>
    A STW Full GC will look at the entire heap and find everything
    that's unreachable at that particular time. A CMS cycle will only
    look at the old gen (and that incrementally, so some objects that
    become unreachable during the cycle might not be collected) and, as
    Mikael pointed out, also assume everything in the young gen is live
    (including objects that might not be). You really need to do a few
    cycles and maybe do some dummy allocations for a while to make sure
    that all weak refs that you are interested have been correctly
    processed by CMS.<br>
    <br>
    General take-away from this: writing such tests is a royal PITA.<br>
    <br>
    Tony<br>
    <br>
    <div class="moz-cite-prefix">On 8/27/13 2:40 AM, Jungwoo Ha wrote:<br>
    </div>
    <blockquote
cite="mid:CA+n_jhgqfR2fbTwkagFujVg1XN_zwZ5J9xBYN-Xg5+6FXkX6iQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Mikael, 
        <div><br>
        </div>
        <div>Does the implicit reference you mentioned should show up in
          the heap dump?</div>
        <div>My collaborator checked the heap dump, and he didn't find
          any pointers to the older classloader other than the weak ref.</div>
        <div><br>
        </div>
        <div>Jungwoo</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Mon, Aug 26, 2013 at 10:35 PM,
          Mikael Gerdin <span dir="ltr"><<a moz-do-not-send="true"
              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">
            <div text="#000000" bgcolor="#ffffff">
              <p>Hi Jungwoo, <br>
                <br>
                The situation I described only affects concurrent
                collections with CMS.<br>
                If the explicit GC is STW (and thereby recorded as a
                Full GC in the log)
                then you should not be seeing any issues. <br>
                <br>
                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. <br>
                <span class="HOEnZb"><font color="#888888">
                    <br>
                    /Mikael<br>
                  </font></span></p>
              <div>
                <div class="h5">
                  <br>
                  <p>
                  </p>
                  <p>On 26 August 2013 23:26:12 Jungwoo Ha wrote:</p>
                  <blockquote type="cite">
                    <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
                            moz-do-not-send="true"
                            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><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 ExplicitGCInvokesConcurrentAndUnloadsClasses
                                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>
                  </blockquote>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Tony Printezis | Staff Software Engineer | Twitter

@TonyPrintezis
<a class="moz-txt-link-abbreviated" href="mailto:tprintezis@twitter.com">tprintezis@twitter.com</a>

</pre>
  </body>
</html>