JVM工具篇-jmap


[root@promote ~]# jmap
Usage:
    jmap [option] 
        (to connect to running process)
    jmap [option] 
        (to connect to a core file)
    jmap [option] [server_id@]
        (to connect to remote debug server)

where 

jmap除了可以导出堆dump,其实还有其他用途,下面逐一介绍,

jmap -heap pid,打印堆概况

[root@promote ~]# jmap -heap 2079
Attaching to process ID 2079, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.281-b09

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 482344960 (460.0MB)
   NewSize                  = 10485760 (10.0MB)
   MaxNewSize               = 160759808 (153.3125MB)
   OldSize                  = 20971520 (20.0MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 9502720 (9.0625MB)
   used     = 846160 (0.8069610595703125MB)
   free     = 8656560 (8.255538940429688MB)
   8.904397898706897% used
Eden Space:
   capacity = 8454144 (8.0625MB)
   used     = 846160 (0.8069610595703125MB)
   free     = 7607984 (7.2555389404296875MB)
   10.008819343507753% used
From Space:
   capacity = 1048576 (1.0MB)
   used     = 0 (0.0MB)
   free     = 1048576 (1.0MB)
   0.0% used
To Space:
   capacity = 1048576 (1.0MB)
   used     = 0 (0.0MB)
   free     = 1048576 (1.0MB)
   0.0% used
tenured generation:
   capacity = 20971520 (20.0MB)
   used     = 431304 (0.41132354736328125MB)
   free     = 20540216 (19.58867645263672MB)
   2.0566177368164062% used

2292 interned Strings occupying 164800 bytes.

jmap -clstats pid,打印使用的类加载器

[root@promote ~]# jmap -clstats 2079
Attaching to process ID 2079, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.281-b09
finding class loader instances ..done.
computing per loader stat ..done.
please wait.. computing liveness..................................................done.
class_loader    classes    bytes    parent_loader    alive?    type

    596    1173669      null      live    
0x00000000e347f6c0    0    0    0x00000000ecd84b60    live    java/util/ResourceBundle$RBClassLoader@0x0000000100077e08
0x00000000ecd84b60    1    1348    0x00000000ecd7c778    live    sun/misc/Launcher$AppClassLoader@0x000000010000f958
0x00000000ecd7c778    0    0      null      live    sun/misc/Launcher$ExtClassLoader@0x000000010000fd00

total = 4    597    1175017        N/A        alive=4, dead=0        N/A  
JVM