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

1

12

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

Stenophyllous answered 28/8, 2018 at 8:33 Comment(2)
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.Andaman
@Andaman yes that solved my problem.Stenophyllous
P
17

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

Placido answered 30/7, 2019 at 9:1 Comment(1)
Got chance to test this today while analyzing another OOM, you are right !Stenophyllous

© 2022 - 2024 — McMap. All rights reserved.