jmap help shows:
...
-dump:<dump-options> to dump java heap in hprof binary format dump-options: live dump only live objects; if not specified, all objects in the heap are dumped.
...
Once I dump a Tomcat (with java param -Xmx384m) heap:
jmap -dump:file=dump.bin <pid>
I got a dump file of ~300M.
When I dump its heap with live objects only:
jmap -dump:live,file=live-dump.bin <pid>
I got a dump file of ~120M.
My guess of live objects may be:
Objects in young generation;
Objects that are used / referenced / reachable and will not be collected.
Which one is right?
UPDATE
My guess #2 seems correct, and thanks for Alexey Ragozin's explanation (live
option will cause a full GC). I tested again according to his hint:
jmap -dump:file=dump.hprof <pid>
jmap -dump:live,file=live-dump.hprof <pid>
jmap -dump:file=after-live-dump.hprof <pid>
size of these 3 files are:
dump.hprof ~190MB
live-dump.hprof ~40MB
after-live-dump.hprof ~40MB
so after -dump:live
, almost all objects in heap are live.