1. Basic Overview of commands
Jmap is a tool that can output all in-memory objects, and even the heap in the VM can be output as text in binary. Print out a Java process (using PID) in memory, all the ' objects ' in the case (e.g., which objects are produced, and their number).
Use the method Jmap-histo pid. If you use the shell, you can save it to a file using the Jmap-histo Pid>a.log log, and after a while, using the text Comparison tool, you can compare which objects the GC recycles. Jmap-dump:format=b,file=outfile 3024 can output the 3024 process memory heap to the outfile file, and then with the Mat (Memory Analysis tool).
The use of 64-bit machines requires the following methods:
Jmap-j-d64-heap PID
2. Command format
l JMAP [option] pid
l JMAP [option] executable core
l jmap [option] [[Email Protected]]remote-hostname-or-ip
3. Parameter description
1), Options:
L Executable: Java executable program that produces core dump;
Core dump file where core will be printed information;
L REMOTE-HOSTNAME-OR-IP the host name or IP of the Remote Debug service;
L Server-id Unique ID, if there are multiple remote debug services on a single host;
2), Basic parameters:
Ø-dump:[live,]format=b,file=<filename> uses the Hprof binary form to output the JVM's heap content to File =. The live sub-option is optional, and if you specify the live option, only the live object is exported to the file.
$jmap –dump:live,format=b,file=aaa.bin 3772
Ø-finalizerinfo printing information for objects that are waiting to be recycled
$jmap-finalizerinfo 3772
Attaching to process ID 3772, please wait ... Debugger attached successfully. Server compiler detected. JVM version is 20.0-B11 Number of objects pending for finalization:0 (0 objects awaiting collection) |
Ø-heap prints the summary of the heap, the algorithm used by the GC, the configuration of the heap, and the use of the wise heap.
$jmap –heap 3772
Using parallel threads in the new generation. # #新生代采用的是并行线程处理方式 Using Thread-local object allocation. Concurrent mark-sweep GC # #同步并行垃圾回收 Heap Configuration: # #堆配置情况 Minheapfreeratio = # #最小堆使用比例 Maxheapfreeratio = # #最大堆可用比例 Maxheapsize = 2147483648 (2048.0MB) # #最大堆空间大小 NewSize = 268435456 (256.0MB) # #新生代分配大小 Maxnewsize = 268435456 (256.0MB) # #最大可新生代分配大小 Oldsize = 5439488 (5.1875MB) # #老生代大小 Newratio = 2 # #新生代比例 Survivorratio = 8 # #新生代与suvivor的比例 PermSize = 134217728 (128.0MB) # #perm区大小 MaxPermSize = 134217728 (128.0MB) # #最大可分配perm区大小 Heap Usage: # #堆使用情况 New Generation (eden + 1 Survivor space): # #新生代 (Eden District + Survior) Capacity = 241631232 (230.4375MB) # #伊甸区容量 used = 77776272 (74.17323303222656MB) # #已经使用大小 Free = 163854960 (156.26426696777344MB) # #剩余容量 32.188004570534986% used # #使用比例 Eden Space: # #伊甸区 Capacity = 214827008 (204.875MB) # #伊甸区容量 used = 74442288 (70.99369812011719MB) # #伊甸区使用 Free = 140384720 (133.8813018798828MB) # #伊甸区当前剩余容量 34.65220164496263% used # #伊甸区使用情况 From Space: # #survior1区 Capacity = 26804224 (25.5625MB) # #survior1区容量 used = 3333984 (3.179534912109375MB) # #surviror1区已使用情况 Free = 23470240 (22.382965087890625MB) # #surviror1区剩余容量 12.43827838477995% used # #survior1区使用比例 To Space: # #survior2 Area Capacity = 26804224 (25.5625MB) # #survior2区容量 Used = 0 (0.0MB) # #survior2区已使用情况 Free = 26804224 (25.5625MB) # #survior2区剩余容量 0.0% used # # Survior2 area use ratio Concurrent Mark-sweep Generation: # #老生代使用情况 Capacity = 1879048192 (1792.0MB) # #老生代容量 used = 30847928 (29.41887664794922MB) # #老生代已使用容量 Free = 1848200264 (1762.5811233520508MB) # #老生代剩余容量 1.6416783843721663% used # #老生代使用比例 Perm Generation: # #perm区使用情况 Capacity = 134217728 (128.0MB) # #perm区容量 used = 47303016 (45.111671447753906MB) # #perm区已使用容量 Free = 86914712 (82.8883285522461MB) # #perm区剩余容量 35.24349331855774% used # #perm区使用比例 |
Ø-histo[:live] Prints the number of instances per class, memory consumption, class full name information. The internal class name of the VM is prefixed with "*". If the live child parameter is added, only the number of live objects is counted.
$jmap –histo:live 3772
Num #instances #bytes class name ---------------------------------------------- 1:65220 9755240 <constMethodKlass> 2:65220 8880384 <methodKlass> 3:11721 8252112 [B 4:6300 6784040 <constantPoolKlass> 5:75224 6218208 [C 6:93969 5163280 <symbolKlass> 7:6300 4854440 <instanceKlassKlass> 8:5482 4203152 <constantPoolCacheKlass> 9:72097 2307104 java.lang.String 10:15102 2289912 [I 11:4089 2227728 <methodDataKlass> 12:28887 1386576 Org.apache.velocity.runtime.parser.Token 13:6792 706368 Java.lang.Class 14:7445 638312 [Ljava.util.hashmap$entry; 15:8770 607040 [S 16:17802 569664 java.lang.ref.WeakReference 17:9538 472688 [[I 18:8439 470440 [Ljava.lang.Object; 19:5168 454784 Java.lang.reflect.Method 20:12559 401888 Java.util.hashmap$entry 21:3730 358080 org.apache.velocity.runtime.parser.node.ASTReference 22:4373 279872 Org.apache.velocity.runtime.parser.node.ASTText 23:463 270392 <objArrayKlassKlass> 24:6695 267800 java.lang.ref.SoftReference 25:5198 249504 Java.util.HashMap 26:2871 206712 Org.apache.velocity.runtime.parser.node.ASTIdentifier 27:7526 180624 Org.apache.velocity.util.introspection.Info 28:4441 177640 Java.util.linkedhashmap$entry 29:5550 177600 Java.util.concurrent.locks.reentrantlock$nonfairsync 30:5723 175272 [Lorg.apache.velocity.runtime.parser.node.Node; 31:4473 156904 [Ljava.lang.String; 32:2773 155288 Java.beans.MethodDescriptor 33:6264 150336 Java.util.ArrayList |
Ø-permstat Prints the classload and JVM heap for a long layer of information. Contains the name of each classloader, the liveliness, the address, the parent ClassLoader, and the number of classes loaded. In addition, the number of internal strings and the amount of memory consumed are also printed.
$jmap-permstat 3772
Class_loader Classes bytes Parent_loader alive? Type <bootstrap> 2172 13144040 NULL Live <internal> 0x00000007882d7ab8 0 0 0x0000000788106c00 dead java/util/[email protected] 0x0000000788c15ca8 1 3136 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788fb1718 1 1968 0x00000007880213d8 dead Sun/reflect/[email protected] 0x00000007882d0f08 1 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788176c60 1 3112 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788a7e018 1 3144 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788f515d0 1 1984 0x00000007880213d8 dead Sun/reflect/[email protected] 0x000000078829a2c8 1 3112 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788fab478 1 3128 null dead Sun/reflect/[email protected] 0x0000000788030fd8 1 3112 0x00000007880213d8 dead Sun/reflect/[email protected] 0x0000000788d46048 1 3144 0x00000007880213d8 dead Sun/reflect/[email protected] 0X000000078816F6F0 1 3144 null dead Sun/reflect/[email protected] 0x0000000788c18850 1 3112 0x00000007880213d8 dead Sun/reflect/[email protected] |
Ø-f force. Use the-dump or-histo parameters when the PID is not appropriate. In this mode, the live sub-argument is invalid.
ø-h | -HELP Printing Auxiliary Information
Ø-j Pass parameters to Jmap-initiated JVM.
Reference documents:
Http://docs.oracle.com/javase/6/docs/technotes/tools/share/jmap.html
http://blog.csdn.net/fenglibing/article/details/6411953
Jmap command Details (EXT)