• JVM工具篇-jmap使用


    [root@promote ~]# jmap
    Usage:
        jmap [option] <pid>
            (to connect to running process)
        jmap [option] <executable <core>
            (to connect to a core file)
        jmap [option] [server_id@]<remote server IP or hostname>
            (to connect to remote debug server)
    
    where <option> is one of:
        <none>               to print same info as Solaris pmap
        -heap                to print java heap summary
        -histo[:live]        to print histogram of java object heap; if the "live"
                             suboption is specified, only count live objects
        -clstats             to print class loader statistics
        -finalizerinfo       to print information on objects awaiting finalization
        -dump:<dump-options> to dump java heap in hprof binary format
                             dump-options:
                               live         dump only live objects; if not specified,
                                            all objects in the heap are dumped.
                               format=b     binary format
                               file=<file>  dump heap to <file>
                             Example: jmap -dump:live,format=b,file=heap.bin <pid>
        -F                   force. Use with -dump:<dump-options> <pid> or -histo
                             to force a heap dump or histogram when <pid> does not
                             respond. The "live" suboption is not supported
                             in this mode.
        -h | -help           to print this help message
        -J<flag>             to pass <flag> directly to the runtime system

    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
    
    <bootstrap>    596    1173669      null      live    <internal>
    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  
  • 相关阅读:
    软件/环境的注册码
    js图片延迟加载如何实现
    http状态码
    关于深拷贝(含数组对象)
    javascript继承方式详解
    使用寄生构造函数 创建类
    前端知识点大全【转载】
    统一addEventListener与attachEvent中this指向问题
    sublime text全程指南【转载】
    函数防抖与节流[转载]
  • 原文地址:https://www.cnblogs.com/feibazhf/p/14457924.html
Copyright © 2020-2023  润新知