Forrest logo
back to the jmap tool

jmap:tldr:ffa13

jmap: Dump live objects of the heap into a binary file for analysis with jhat.
$ jmap -dump:live,format=b,file=${filename} ${java_pid}
try on your machine

The command "jmap -dump:live,format=b,file=${filename} ${java_pid}" is used to capture a heap dump of a running Java process.

Here's the breakdown of the command:

  1. "jmap" is a command-line utility provided by the Java Development Kit (JDK). It is used to obtain details about the memory usage of a running Java process, including heap utilization.

  2. "-dump:live" is an option that instructs jmap to capture a heap dump of only live objects. Live objects are the ones that are still referenced by the application and actively used.

  3. "format=b" specifies the format of the heap dump to be in binary format.

  4. "file=${filename}" is used to specify the filename and path where the heap dump will be saved. You need to replace "${filename}" with the desired name and location of the heap dump file.

  5. "${java_pid}" is a placeholder for the process ID (PID) of the Java process for which you want to capture the heap dump. You need to replace "${java_pid}" with the actual PID of the Java process.

When you run this command, jmap will connect to the specified Java process, capture a snapshot of the live objects in the Java heap, and save it as a binary heap dump file with the specified filename and path. This heap dump can be analyzed using various tools to troubleshoot memory-related issues or to get insights into the memory usage of the Java application.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the jmap tool