Forrest logo
tool overview
On this page you find all important commands for the CLI tool jmap. If the command you are looking for is missing please ask our AI.

jmap

jmap is a command line tool that is commonly used in Java development environments. It is a part of the JDK (Java Development Kit) and is primarily used for troubleshooting and analyzing Java heap memory usage. The tool allows you to obtain detailed information about objects present in the Java heap, including their sizes, number of instances, and memory location.

You can use jmap to generate heap dumps, which are snapshots of the Java heap memory at a particular point in time. These heap dumps provide valuable information about the state of the Java application and allow you to identify memory leaks and inefficient memory usage.

jmap also has the ability to connect to running Java processes and obtain information about their heap memory usage. This is particularly useful when you need to analyze the memory usage of a Java application in a production environment.

Apart from heap dumps, jmap can also generate other useful information like a histogram, which provides a summary of the objects in the heap categorized by their class types. This helps you understand which classes are consuming the most memory in your application.

The tool can also be used to perform some basic memory leak analysis by comparing two heap dumps taken at different points in time. By analyzing the differences in object instances between the two dumps, you can identify potential memory leaks in your application.

jmap supports various command-line options, which allow you to customize the output and perform specific memory-related operations. For example, you can use the '-histo' option to generate a histogram or the '-dump:format=b,file=' option to generate a heap dump in binary format.

Overall, jmap is a powerful command line tool for analyzing Java heap memory usage and troubleshooting memory-related issues in Java applications. It provides developers and administrators with valuable insights into the memory consumption and object allocation within their applications.

List of commands for jmap:

  • jmap:tldr:76ca3 jmap: Print histogram of heap usage by type.
    $ jmap -histo ${java_pid}
    try on your machine
    explain this command
  • jmap:tldr:8f459 jmap: Print heap summary information.
    $ jmap -heap ${filename-jar} ${java_pid}
    try on your machine
    explain this command
  • jmap:tldr:ae628 jmap: Print shared object mappings for a Java process (output like pmap).
    $ jmap ${java_pid}
    try on your machine
    explain this command
  • jmap:tldr:ef5b3 jmap: Dump contents of the heap into a binary file for analysis with jhat.
    $ jmap -dump:format=b,file=${filename} ${java_pid}
    try on your machine
    explain this command
  • 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
    explain this command
tool overview