LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

jmap

prints memory-related statistics for Java processes

TLDR

Print class loader statistics
$ jmap -clstats [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-related statistics for Java processes. It generates heap dumps, object histograms, and class loader statistics.The tool is essential for memory analysis and leak detection. Heap dumps can be analyzed with tools like Eclipse MAT or VisualVM.

PARAMETERS

PID

Target Java process ID.
-clstats pid
Print class loader statistics of the Java heap.
-finalizerinfo pid
Print information on objects awaiting finalization.
-histo[:live]
Print histogram of the Java object heap. With :live, counts only live objects.
-dump:options
Dump the Java heap. Sub-options:
:live
Only live objects.
:format=b
Binary hprof format.
:file=FILE
Output file path.

CAVEATS

Part of JDK. This command is experimental and unsupported; it may not be available in future JDK releases. May pause the application during heap dump. Large heaps create large dump files.

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)

Copied to clipboard
Kai