您好,登錄后才能下訂單哦!
前言
大家都知道有很多開源的監控工具,本次只使用了jmap,了解簡單使用,謝謝,下面話不多說了,來一起看看詳細的介紹吧
使用方法如下:
開始了,922是我的tomcat進程
幫助命令查看,有哪些命令可以使用。
[root@bogon /]# jmap -help 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
使用1:jmap pid 查看基本信息
[root@bogon /]# jmap 922 Attaching to process ID 922, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.111-b14 0x0000000000400000 7K /usr/local/software/java/bin/java 0x0000003ddde00000 153K /lib64/ld-2.12.so 0x0000003dde200000 22K /lib64/libdl-2.12.so 0x0000003dde600000 1881K /lib64/libc-2.12.so 0x0000003ddea00000 142K /lib64/libpthread-2.12.so 0x0000003ddee00000 45K /lib64/librt-2.12.so 0x0000003ddf200000 585K /lib64/libm-2.12.so 0x0000003de0e00000 111K /lib64/libresolv-2.12.so 0x0000003de9e00000 91K /lib64/libgcc_s-4.4.7-20120601.so.1 0x00007f90de586000 26K /lib64/libnss_dns-2.12.so 0x00007f913c39d000 250K /usr/local/software/java/jre/lib/amd64/libsunec.so 0x00007f913cbf2000 90K /usr/local/software/java/jre/lib/amd64/libnio.so 0x00007f913d103000 113K /usr/local/software/java/jre/lib/amd64/libnet.so 0x00007f913d31a000 49K /usr/local/software/java/jre/lib/amd64/libmanagement.so 0x00007f919a43b000 121K /usr/local/software/java/jre/lib/amd64/libzip.so 0x00007f919a656000 64K /lib64/libnss_files-2.12.so 0x00007f919a874000 220K /usr/local/software/java/jre/lib/amd64/libjava.so 0x00007f919aaa0000 64K /usr/local/software/java/jre/lib/amd64/libverify.so 0x00007f919acef000 16584K /usr/local/software/java/jre/lib/amd64/server/libjvm.so 0x00007f919bce2000 100K /usr/local/software/java/lib/amd64/jli/libjli.so
使用2 :查看堆信息,jmap -heap pid
[root@bogon /]# jmap -heap 922 Attaching to process ID 922, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.111-b14 using parallel threads in the new generation. using thread-local object allocation. Concurrent Mark-Sweep GC Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 4294967296 (4096.0MB) 最大堆大小 NewSize = 3221225472 (3072.0MB) 新生代大小 MaxNewSize = 3221225472 (3072.0MB) 最大分配新生代內存 OldSize = 1073741824 (1024.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 = 2899116032 (2764.8125MB) used = 384206560 (366.4079284667969MB) free = 2514909472 (2398.404571533203MB) 13.25254166301682% used Eden Space: 新生代 eden區空間 capacity = 2577006592 (2457.625MB) used = 378654344 (361.11292266845703MB) free = 2198352248 (2096.512077331543MB) 14.693572968555294% used From Space: 2個Survivor區域 其中一個就是這個from區 capacity = 322109440 (307.1875MB) used = 5552216 (5.295005798339844MB) free = 316557224 (301.89249420166016MB) 1.723704837709817% used To Space:2個Survivor區域 其中一個就是這個to區 capacity = 322109440 (307.1875MB) used = 0 (0.0MB) free = 322109440 (307.1875MB) 0.0% used concurrent mark-sweep generation: 老年代 eden區空間 capacity = 1073741824 (1024.0MB) used = 846734040 (807.5085067749023MB) free = 227007784 (216.49149322509766MB) 78.85825261473656% used
使用3:jmap -histo pid 查看一些class的使用情況,
jmap -histo 922 由于里面比較多內容,所以放棄了,可以自己使用一下,如果電腦展示不了一屏呢,可以這樣。 jmap -histo 922 >dump.txt 導出文件,可以自己看了 下面是我自己導出的文件信息 num #instances(實例數量) #bytes(字節) class name ---------------------------------------------- 1: 174069 1579369600 [C 2: 4403 122732640 [I 3: 9571 16889072 [B 4: 157680 3784320 java.lang.String 5: 38279 3674784 java.util.jar.JarFile$JarFileEntry 6: 70982 2271424 java.util.HashMap$Node 7: 13235 1164680 java.lang.reflect.Method 8: 6001 1028952 [Ljava.util.HashMap$Node; 又或者可以過濾信息,命令:jmap -histo 922 |grep dubbo 過濾一下,就過濾你想要的信息
使用4:jmap -histo:live pid >dump.txt
這個和使用3差不多,都是在統計,只不過這個是在統計正在使用的對象,然后dump對象信息。
這種命令都是結合其它的命令一起使用的,以后會有文章結合一起分析,同學有什么好的工具也分享出來,一起學習,本篇只介紹jmap
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。