why there is difference in Heap dump size generated by jmap and jcmd?

Vipin :

I am trying to take heap dump using below 2 commands

  1. jcmd $pid GC.heap_dump /tmp/filename.dump
  2. jmap -dump:format=b,file=/tmp/filename.dump $pid

jcmd produces file size of ~300M and jmap produces file size of ~1.4G. why these are different sizes, do we have any additional information in jmap ? am I missing some arguments in jcmd ?

JDK is 1.8.0_162

Xms and Xmx is 4G

Narasimman SP :

JMAP took an all-objects dump and JCMD took an only live-objects dump.

Using JCMD command: While using this command you have to pass -all option. Otherwise, it will request a full GC and generates only live objects dump.

Using JMAP command: While using this command you don't need to specify anything as it is by default produce the heap dump of all the objects. If you need live objects alone, you can pass 'live' option in JMAP.

JCMD - without any options of object state - By default it dumps only the live objects. JMAP - without any options of object state - By default it dumps all the objects.

For more information refer here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=79847&siteId=1