JVM Memory Analysis - fieldenms/tg GitHub Wiki
This wiki contains some notes on tools that we found useful when analysing the memory usage by Java applications.
jps
- list the instrumented JVMs on the target system with their name and PID; this is one of the standard JDK utilities, available on the command line; refer to https://docs.oracle.com/en/java/javase/19/docs/specs/man/jps.html for more details.
jcmd
– send diagnostic command requests to a running Java Virtual Machine (JVM); this is one of the standard JDK utilities, available on the command line; refer to https://docs.oracle.com/en/java/javase/19/docs/specs/man/jcmd.html for more details.
The jcmd
utility can be used to capture the heap dump of a Java process: jcmd <pid> GC.heap_dump <file-path>
.
For example, running jcmd 7232 GC.heap_dump heap.hprof
would dump the heap of the Java process with PID 7232
to file heap.hprof
.
The captured heap dump can be conveniently analysed by the Eclipse Memory Analyser (MAT), which can be found at https://www.eclipse.org/mat/.
And of course, one can use the Java Mission Control and Java Flight Recorder (https://github.com/openjdk/jmc).