jmap - print details of a specified process
jmap -histo[:live] pid
jmap -dump:[live,]format=b,file=<file> pid
Options you will use
-histo[:live[,file=<f>]]- Class histogram.
:liveforces a full GC first and counts only reachable objects. -dump:live,format=b,file=<f>- Heap dump in HPROF format. The path is resolved on the client side.
-clstats- Class loader statistics.
-histo:live- Class histogram of the LIVE objects only: forces a full GC first, then counts what is still reachable.
-heap- REMOVED in JDK 9+: "Invalid option". Use
jhsdb jmap --heap --pid PIDorjcmd PID GC.heap_info.
Examples
$ jmap -histo:live 1210 | head -15Top classes by bytes.
$ jmap -dump:live,format=b,file=/tmp/orders.hprof 1210Dump for Eclipse MAT.
Gotchas
jmap -heapwas removed in JDK 9: usejcmd <pid> GC.heap_info(orjhsdb jmap --heap).- Diff two histograms taken a minute apart: the class whose count only ever grows is your leak candidate.
[Band String are always near the top - that alone means nothing.
Taught in
Try jmap in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.