Fourth Chapter: Java Virtual Machine command-line tools
1:JPS command line process Status Tool JPS [options] [HostID]
C:\users\lenovo>jps-l
13824 Sun.tools.jps.Jps
14224 Org.jetbrains.jps.cmdline.Launcher
8528 Org.jetbrains.idea.maven.server.RemoteMavenServer
12660 Org.jetbrains.jps.cmdline.Launcher
7316
11544
236 Com.li.SpringBootLabApplication//main class
2:jstat a command-line tool for monitoring the various health status information for a virtual machine. Including class loading, memory, garbage Collection, JIT compilation and other data
jstat [option Vmid [interval [S|ms][count]]
Option represents the virtual machine information that the user wants to query
For example, every 250 milliseconds to query the garbage collection information of process 236, query 20 times
3:jinfo Printing Java configuration information
Printing process
Jinfo 236 's information
C:\users\lenovo>jinfo236attaching to process ID236, please wait ... Debugger attached successfully. Server compiler detected. JVM version is 25.161-B12java System Properties:java.runtime.name=Java (TM) SE Runtime Environmentjava.vm.version=25.161-B12sun.boot.library.path= D:\software\jdk\jdk8\jdk1.8. 0_161\jre\binjava.vendor.url= http://java.oracle.com/Java.vm.vendor =Oracle Corporationpath.separator=; file.encoding.pkg=Sun.iojava.vm.name= Java HotSpot (TM) --Bit Server VMsun.os.patch.level=Sun.java.launcher=Sun_standarduser.script=User.country=Cnuser.dir=D:\software\github\github Download \laboratorywebjava.vm.specification.name=Java Virtual Machine specificationpid=236java.runtime.version=1.8.0_161-b12java.awt.graphicsenv=Sun.awt.Win32GraphicsEnvironmentos.arch=Amd64java.endorsed.dirs= D:\software\jdk\jdk8\jdk1.8. 0_161\jre\lib\endorsedorg.jboss.logging.provider=Slf4jline.separator=Java.io.tmpdir=C:\Users\lenovo\AppData\Local\Tempjava.vm.specification.vendor=Oracle corporationuser.variant=Os.name= WindowsTensun.jnu.encoding=GBKjava.library.path= D:\software\jdk\jdk8\jdk1.8.0_161\bin; C:\Users\lenovo\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm\5.0.3\dcc2193db20e19e1feca8b1240dbbc4e190824fa\asm-5.0.3. jar;d:\software\ideaj\ideaic-2017.3.4. Win\lib\idea_rt.jarjava.vm.specification.version=1.8Sun.arch.data.model= -Sun.java.command=Com.li.SpringBootLabApplicationjava.home= D:\software\jdk\jdk8\jdk1.8. 0_161\jreuser.language=Zhjava.specification.vendor=Oracle Corporationawt.toolkit=Sun.awt.windows.WToolkitjava.vm.info=Mixed Modejava.version=1.8. 0_161java.ext.dirs= D:\software\jdk\jdk8\jdk1.8. 0_161\jre\lib\ext; C:\WINDOWS\Sun\Java\lib\extsun.boot.class. Path = D:\software\jdk\jdk8\jdk1.8.0_161\jre\lib\resources.jar;d:\software\jdk\jdk8\jdk1.8. 0_161\jre\classesjava.awt.headless=trueJava.vendor=Oracle Corporationcatalina.Base= C:\Users\lenovo\AppData\Local\Temp\tomcat.6690132104814217884.9002File.separator=Java.vendor.url.bug= http://bugreport.sun.com/bugreport/Sun.io.unicode.encoding =UnicodeLittlesun.cpu.endian=Littlesun.desktop=windowssun.cpu.isalist=AMD64VM Flags:non-defaultVM Flags:-xx:cicompilercount=3-xx:initialheapsize=134217728-xx:maxheapsize=2122317824-xx:maxnewsize=707264512-xx:minheapdeltabytes=524288-xx:newsize=44564480-xx:oldsize=89653248-xx:+usecompressedclasspointers-xx:+usecompressedoops-xx:+usefastunorderedtimestamps-xx:- uselargepagesindividualallocation-xx:+Useparallelgccommand Line:-javaagent:d:\software\ideaj\ideaic-2017.3.4. win\lib\idea_rt.jar=50372:D: \software\ideaj\ideaic-2017.3.4. win\bin-dfile.encoding=utf-8
4:jmap:java Memory Imaging Tool
For example, show Java heap details
Jmap-heap 236
C:\users\lenovo>jmap-heap236attaching to process ID236, please wait ... Debugger attached successfully. Server compiler detected. JVM version is 25.161-B12usingThread-localObjectallocation. Parallel GC with4thread (s) Heap Configuration:minheapfreeratio=0Maxheapfreeratio= -maxheapsize=2122317824(2024. 0MB) NewSize=44564480( the. 5MB) Maxnewsize=707264512(674. 5MB) Oldsize=89653248( -. 5MB) Newratio=2Survivorratio=8metaspacesize=21807104( -. 796875MB) Compressedclassspacesize=1073741824(1024x768. 0MB) Maxmetaspacesize=17592186044415MB g1heapregionsize=0(0. 0MB) Heap usage:ps Young Generationeden space:capacity=195035136(186. 0MB) Used=71367536( the. 06138610839844MB) Free=123667600(117. 93861389160156MB)36.592143069031415%Usedfrom space:capacity=17825792( -. 0MB) Used=17497968( -. 687362670898438MB) Free=327824(0. 3126373291015625MB)98.16095688763787%usedto space:capacity=14155776( -. 5MB) Used=0(0. 0MB) Free=14155776( -. 5MB)0.0%Usedps old Generation capacity=112197632(107. 0MB) Used=23719728( A. 620895385742188MB) Free=88477904( -. 37910461425781MB)21.1410237249927%used24236Interned Strings occupying2896624bytes. C:\Users\lenovo>
5:jhat virtual machine heap dump snapshot analysis tool
6:jstack:java Stack Trace Tool
7:hsdis JIT-generated code disassembly
Visualization tools:
All locally run virtual machine processes will be searched through the Jconsole.exe startup Jconsole in the Jdk/bin directory.
Select a process to monitor: View information for each status
Deep understanding of Java virtual machines