Search This Blog

Java: jmap heap dump

To capture a heap dump using jmap we need to use the dump option:
jmap -dump:[live],format=b,file=<file-path> <pid>

Along with that option, we should specify several parameters:
  • live: if set it only prints objects which have active references and discards the ones that are ready to be garbage collected. This parameter is optional
  • format=b: specifies that the dump file will be in binary format. If not set the result is the same
  • file: the file where the dump will be written to
  • pid: id of the Java process

An example would be like this:
jmap -dump:live,format=b,file=/tmp/dump.hprof 12587


see also

No comments:

Post a Comment