也有很多开源的监控恐惧,本次只使用了jmap,了解简单使用,谢谢
开始了,922是我的tomcat进程
帮助命令查看,有哪些命令可以使用。
[root@bogon /]# jmap -helpUsage: 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 922Attaching to process ID 922, please wait...Debugger attached successfully.Server compiler detected.JVM version is 25.111-b140x0000000000400000 7K /usr/local/software/java/bin/java0x0000003ddde00000 153K /lib64/ld-2.12.so0x0000003dde200000 22K /lib64/libdl-2.12.so0x0000003dde600000 1881K /lib64/libc-2.12.so0x0000003ddea00000 142K /lib64/libpthread-2.12.so0x0000003ddee00000 45K /lib64/librt-2.12.so0x0000003ddf200000 585K /lib64/libm-2.12.so0x0000003de0e00000 111K /lib64/libresolv-2.12.so0x0000003de9e00000 91K /lib64/libgcc_s-4.4.7-20120601.so.10x00007f90de586000 26K /lib64/libnss_dns-2.12.so0x00007f913c39d000 250K /usr/local/software/java/jre/lib/amd64/libsunec.so0x00007f913cbf2000 90K /usr/local/software/java/jre/lib/amd64/libnio.so0x00007f913d103000 113K /usr/local/software/java/jre/lib/amd64/libnet.so0x00007f913d31a000 49K /usr/local/software/java/jre/lib/amd64/libmanagement.so0x00007f919a43b000 121K /usr/local/software/java/jre/lib/amd64/libzip.so0x00007f919a656000 64K /lib64/libnss_files-2.12.so0x00007f919a874000 220K /usr/local/software/java/jre/lib/amd64/libjava.so0x00007f919aaa0000 64K /usr/local/software/java/jre/lib/amd64/libverify.so0x00007f919acef000 16584K /usr/local/software/java/jre/lib/amd64/server/libjvm.so0x00007f919bce2000 100K /usr/local/software/java/lib/amd64/jli/libjli.so
使用2 :查看堆信息,jmap -heap pid
[root@bogon /]# jmap -heap 922Attaching to process ID 922, please wait...Debugger attached successfully.Server compiler detected.JVM version is 25.111-b14using parallel threads in the new generation. using thread-local object allocation.Concurrent Mark-Sweep GCHeap 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% usedEden Space: 新生代 eden区空间 capacity = 2577006592 (2457.625MB) used = 378654344 (361.11292266845703MB) free = 2198352248 (2096.512077331543MB) 14.693572968555294% usedFrom Space: 2个Survivor区域 其中一个就是这个from区 capacity = 322109440 (307.1875MB) used = 5552216 (5.295005798339844MB) free = 316557224 (301.89249420166016MB) 1.723704837709817% usedTo Space:2个Survivor区域 其中一个就是这个to区 capacity = 322109440 (307.1875MB) used = 0 (0.0MB) free = 322109440 (307.1875MB) 0.0% usedconcurrent 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
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦