10

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

Vipin
  • 4,851
  • 3
  • 35
  • 65
  • 1
    Have you tried to run jmap without the format param, i.e. jmap -dump:file=... ? Oracle suggests that 1. and 2. are equivalent when format parameter is missing from the jmap command. – jkonst Aug 28 '18 at 13:14
  • @jkonst yes that solved my problem. – Vipin Aug 03 '19 at 15:51

1 Answers1

15

By Default (When no [options] are provided],

JMAP took an all-objects dump and JCMD took 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 '-dump:live' option in JMAP.

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.

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

Narasimman SP
  • 176
  • 2
  • 5