<div dir="ltr">







<p class=""><font size="1"><span class="">hello </span><span class="">all,</span><br>     <br>     We recently used "jmap -dump: live heap,format=b,file=heap.bin <pid>”  to dump the heap file for analysis . by the official doc,  the “live” option means the jmap will do a<br>a full gc before dump, but unfortunately, I found  there are lots of unreachable objects in final dumped file even I used the “live” option (which sounds the jmap doesn’t do a full gc  before dump)<br><br>In my test application,  the "cms gc" is used. By investigating the relevant GC implementation in HotSpot,  the code shows  jmap only triggered  the collection in old generation,  the young collection is skipped.<br>Pls. check the implementation in  GenCollectedHeap::do_collection(genCollectedHeap.cpp), which has the below logic:<br> int starting_level = 0;<br>  if (full) {<br>      for (int i = max_level; i >= 0; i--) {<br><span class="">        if (_gens[i]->full_collects_younger_generations()) {          </span><span class="">ß</span><br>          starting_level = i;<br>          break;<br>        }<br>      }<br>  }<br> <br>In jmap with live option case,  the full_collects_younger_generations will return true :<br><br>virtual bool full_collects_younger_generations() const {<br>    return UseCMSCompactAtFullCollection && !CollectGen0First;<br>}<br><br>so that the starting_level gets “1” (old generation) ,  <br>This means the collection in young generation (level = “0”) will be skipped, see:<br> <br>    for (int i = starting_level; i <= max_level; i++) {<br>      if (_gens[i]->should_collect(full, size, is_tlab)) {<br> <br> <br>I am wondering if this is  a potential bug  when the user used the jmap with live option?<br>Your suggestion?</font><br></p>



<p class=""><span class="">








</span></p>






<p class=""><span class="">










</span></p>







</div>