Rate This Document
Findability
Accuracy
Completeness
Readability

jmap

Introduction

jmap is a tool provided by the JDK to view and debug heap information. It can be used to export heap information to files for analysis and view heap space allocation information. jmap is a common tool for Java performance tuning.

Installation Method

After the JDK is installed, the jmap tool is delivered with the JDK and you do not need to install it. The jmap tool is generally stored in the bin directory of Java.

How to Use

Command format: jmap [Parameter]

Common parameters are as follows:

Parameter

Description

Example

-dump:[live,]format=b,file=/you/path/filename.hprof <pid>

Exports the heap object content of the JVM to a specified file. You are advised to name the file in .hprof format, which can be analyzed using the MAT tool. The live option is optional. If live is selected, only live objects are exported to a file.

jmap -dump:format=b,file=/opt/log/java12123.hprof 12123

-finalizerinfo <pid>

Outputs the information about the objects that are waiting to be reclaimed.

jmap -finalizerinfo 12123

-heap <pid>

Outputs the summary statistics on the heap of the current Java process, such as the GC algorithm and heap configuration space.

jmap -heap 12123

-histo[:live] <pid>

Displays the number of instances of the current class, memory usage, and full name of the class.

jmap -histo:live 12123 | head -n 20

-permstat <pid>

Prints classload and permanent generation information in the JVM heap, including the name, liveliness, address, parent classloader, and number of loaded classes of each classloader.

jmap -permstat 12123

jmap -heap <pid> example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using parallel threads in the new generation.
using thread-local object allocation.   
Concurrent Mark-Sweep GC ##Synchronous concurrent garbage collection
Heap Configuration:
   MinHeapFreeRatio = 40 ##Minimum heap usage.
   MaxHeapFreeRatio = 70 ##Maximum available heap ratio.
   MaxHeapSize      = 2147483648 (2048.0 MB) ##Maximum size of the heap space.
   NewSize          = 268435456 (256.0 MB) ##Size of the young generation.
   MaxNewSize       = 268435456 (256.0 MB) ##Maximum size of the young generation.
   OldSize          = 5439488 (5.1875 MB) ##Size of the old generation.
   NewRatio         = 2  ##Ratio of the young generation.
   SurvivorRatio    = 8 ##Ratio of the young generation to the survivor
   PermSize         = 134217728 (128.0 MB) ##Size of the perm.
   MaxPermSize      = 134217728 (128.0 MB) ##Maximum allocatable size of the perm.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 241631232 (230.4375 MB) ##Capacity of Eden.
   used     = 77776272 (74.17323303222656 MB) ##Used size.
   free     = 163854960 (156.26426696777344 MB) ##Remaining capacity.
   32.188004570534986% used ##Usage percentage.
Eden Space:
   capacity = 214827008 (204.875 MB) ##Capacity of Eden.
   used     = 74442288 (70.99369812011719 MB) ##Used capacity of Eden.
   free     = 140384720 (133.8813018798828 MB) ##Remaining capacity of Eden.
   34.65220164496263% used ##Usage of Eden.
From Space: ##survivor 1
   capacity = 26804224 (25.5625 MB) ##Capacity of survivor 1.
   used     = 3333984 (3.179534912109375 MB) ##Usage of survivor 1.
   free     = 23470240 (22.382965087890625 MB) ##Remaining capacity of survivor 1.
   12.43827838477995% used ##Usage percentage of survivor 1.
To Space: ##survivor 2
   capacity = 26804224 (25.5625 MB) ##Capacity of survivor 2.
   used     = 0 (0.0 MB) ##Usage of survivor 2.
   free     = 26804224 (25.5625 MB) ##Remaining capacity of survivor 2.
   0.0% used ##Usage percentage of survivor 2.
concurrent mark-sweep generation: ##Usage of the old generation.
   capacity = 1879048192 (1792.0 MB) ##Capacity of the old generation.
   used     = 30847928 (29.41887664794922 MB) ##Used capacity of the old generation.
   free     = 1848200264 (1762.5811233520508 MB) ##Remaining capacity of the old generation.
   1.6416783843721663% used ##Usage percentage of the old generation.
Perm Generation: ##Usage of the permanent generation.
   capacity = 134217728 (128.0 MB) ##Capacity of the permanent generation.
   used     = 47303016 (45.111671447753906 MB) ##Used capacity of the permanent generation.
   free     = 86914712 (82.8883285522461 MB) ##Remaining capacity of the permanent generation.
   35.24349331855774% used ##Usage percentage of the permanent generation.

Source: CSDN forum