LinuxCommandLibrary

jmap

TLDR

Print heap summary

$ jmap -heap [pid]
copy
Dump heap to file
$ jmap -dump:format=b,file=[heap.hprof] [pid]
copy
Dump live objects only
$ jmap -dump:live,format=b,file=[heap.hprof] [pid]
copy
Histogram of objects
$ jmap -histo [pid]
copy
Live objects histogram
$ jmap -histo:live [pid]
copy

SYNOPSIS

jmap [options] pid

DESCRIPTION

jmap prints memory maps for Java processes. It generates heap dumps and object histograms.
The tool is essential for memory analysis and leak detection. Heap dumps can be analyzed with tools like MAT.
jmap creates Java heap dumps.

PARAMETERS

PID

Target Java process ID.
-heap
Print heap summary.
-histo
Print object histogram.
-dump:OPTIONS
Dump heap to file.
:live
Only live objects.
:format=b
Binary format.
:file=FILE
Output file.
--help
Display help information.

CAVEATS

Part of JDK. May pause application. Large heaps create large dumps.

HISTORY

jmap has been part of the JDK since Java 5, providing memory analysis capabilities for running Java processes.

SEE ALSO

jhat(1), jstack(1), jinfo(1), jcmd(1)

Copied to clipboard