There is also a lot of open source monitoring fear, this time only use Jmap, understand the simple use, thank you
922 is my tomcat process.
Help commands to see what commands are available.
[[email protected]/]# jmap-helpusage:jmap [option] <pid> (to connect to running process) Jmap [ Option] <executable <core> (to connect to a core file) jmap [option] [[Email protected]]<remote Server IP or hostname> (to connect to remote debugging 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 CLA SS Loader Statistics-finalizerinfo to print information on objects awaiting finalization-dump:<dump-optio ns> 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 & Lt;pid> does not respond. The "Live" suboption is not a supported in this mode. -H | -help to print this-help message-j<flag>-pass <flag> directly to the runtime Syst Em
use 1:jmap PID to view basic information
[[email protected]/]# 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.so0x0 000003de0e00000 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
use 2: View heap information, jmap-heap PID
[[email protected]/]# 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 = + Maxheapfreeratio = maxheapsize = 4294967296 (4096.0MB) maximum heap size NewSize = 3221225472 (3072.0MB) Cenozoic size maxnewsize = 3221225472 (3072.0MB) maximum allocation of cenozoic memory Oldsize = 1073741824 (1024.0MB) old age size Newratio = 2 Survivorratio = 8 The ratio of the new generation to the old age metaspacesize = 21807104 (20.796875MB) Compressedclassspac Esize = 1073741824 (1024.0MB) maxmetaspacesize = 17592186044415 MB g1heapregionsize = 0 (0.0MB) Heap Us Age: Heap Usage new Generation (Eden + 1 Survivor Space): Cenozoic capacity = 2899116032 (2764.8125MB) used = 384206560 (366 .4079284667969MB) Free = 2514909472 (2398.404571533203MB) 13.25254166301682% Usededen space: New generation Eden Zone capacity = 2577006592 (24 57.625MB) used = 378654344 (361.11292266845703MB) free = 2198352248 (2096.512077331543MB) 14.693572968555294 % usedfrom Space:2 survivor Zone One of them is the from zone capacity = 322109440 (307.1875MB) used = 5552216 (5.295005798339844MB ) free = 316557224 (301.89249420166016MB) 1.723704837709817% usedto space:2 survivor area One of them is this to zone capacity = 32 2109440 (307.1875MB) used = 0 (0.0MB) free = 322109440 (307.1875MB) 0.0% usedconcurrent mark-sweep Generatio N: The old age Eden zone Space capacity = 1073741824 (1024.0MB) used = 846734040 (807.5085067749023MB) free = 227007784 (216 .49149322509766MB) 78.85825261473656% used
Use the 3:jmap-histo PID to view some class usage,
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 过滤一下,就过滤你想要的信息
Using the 4:jmap-histo:live PID >dump.txt
This is the same as using 3, all in statistics, except that this is the object that is being used in the statistics, and then dump the object information.
This command is combined with other commands to use, and later there will be a combination of articles to analyze, students have what good tools to share, learn together, this article only introduce Jmap
Java virtual machine jmap use