美文网首页
jmap工具

jmap工具

作者: 树琦 | 来源:发表于2020-06-27 20:22 被阅读0次

    ​ jmap命令是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本。打印出某个java进程(使用pid)内存内的,所有‘对象’的情况(如:产生那些对象,及其数量)。

    语法

    C:\Users\shuqi>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
    

    生成dump文件

    C:\Users\shuqi>jmap -dump:live,format=b,file=d:\\d.bin 9880
    Dumping heap to D:\d.bin ...
    Heap dump file created
    

    打印Heap信息

    C:\Users\shuqi>jmap -heap 9880
    Attaching to process ID 9880, please wait...
    Debugger attached successfully.
    Server compiler detected.
    JVM version is 25.111-b14
    
    using thread-local object allocation.
    Parallel GC with 8 thread(s)
    
    Heap Configuration:
       MinHeapFreeRatio         = 0
       MaxHeapFreeRatio         = 100
       MaxHeapSize              = 1073741824 (1024.0MB)
       NewSize                  = 44564480 (42.5MB)
       MaxNewSize               = 357564416 (341.0MB)
       OldSize                  = 89653248 (85.5MB)
       NewRatio                 = 2
       SurvivorRatio            = 8
       MetaspaceSize            = 21807104 (20.796875MB)
       CompressedClassSpaceSize = 1073741824 (1024.0MB)
       MaxMetaspaceSize         = 17592186044415 MB
       G1HeapRegionSize         = 0 (0.0MB)
    
    Heap Usage:
    PS Young Generation
    Eden Space:
       capacity = 26214400 (25.0MB)
       used     = 1048720 (1.0001373291015625MB)
       free     = 25165680 (23.999862670898438MB)
       4.00054931640625% used
    From Space:
       capacity = 524288 (0.5MB)
       used     = 294912 (0.28125MB)
       free     = 229376 (0.21875MB)
       56.25% used
    To Space:
       capacity = 524288 (0.5MB)
       used     = 0 (0.0MB)
       free     = 524288 (0.5MB)
       0.0% used
    PS Old Generation
       capacity = 54001664 (51.5MB)
       used     = 13028944 (12.425369262695312MB)
       free     = 40972720 (39.07463073730469MB)
       24.126930607175364% used
    
    11332 interned Strings occupying 1040832 bytes.
    

    相关文章

      网友评论

          本文标题:jmap工具

          本文链接:https://www.haomeiwen.com/subject/vaivfktx.html