jmap with live option does not do a full gc(ygc is skipped) before dump

李嘉鹏 nijiaben at gmail.com
Mon May 11 12:56:55 UTC 2015


hello all,


 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
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)

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.
Pls. check the implementation in
 GenCollectedHeap::do_collection(genCollectedHeap.cpp), which has the below
logic:
 int starting_level = 0;
  if (full) {
      for (int i = max_level; i >= 0; i--) {
        if (_gens[i]->full_collects_younger_generations()) {          ß
          starting_level = i;
          break;
        }
      }
  }

In jmap with live option case,  the full_collects_younger_generations will
return true :

virtual bool full_collects_younger_generations() const {
    return UseCMSCompactAtFullCollection && !CollectGen0First;
}

so that the starting_level gets “1” (old generation) ,
This means the collection in young generation (level = “0”) will be
skipped, see:

    for (int i = starting_level; i <= max_level; i++) {
      if (_gens[i]->should_collect(full, size, is_tlab)) {


I am wondering if this is  a potential bug  when the user used the jmap
with live option?
Your suggestion?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20150511/d120894f/attachment.html>


More information about the hotspot-gc-dev mailing list