jps
(JVM Process Status Tool): displays all the HotSpot virtual machine process within the specified systemjstat
(JVM Statistics Monitoring Tool): User data collection run all aspects of the HotSpot virtual machinejinfo
(Configuration Info for Java): real-time view and adjust the parameters of the virtual machine, integrated into in JDK9jhsdb
jmap
(Memory Map for java): generate a memory dump snapshot of the virtual machine, integrated into in JDK9jhsdb
jhat
(JVM Heap Dump Browser): analysis of user heapdump file, it will create a HTTP / HTML server, so that users can view the results on the browser integrated into the in JDK9jhsdb
jstack
(Stack Trace for Java): generates a virtual machine snapshot of the current time of thread, integrated into in JDK9jhsdb
jhsdb
(Java HotSport Debugger): Process Debugger, introduced in JDK9
jps
Lists the virtual machine processes running on the current machine, jps command format:
jps [option] [hostid]
-p: VM label only display, the display information does not jar, class, main parameters.
-m: output main function of the parameters passed hello parameters when executing the program is entered from the command line.
-l: Output application The main class name or jar full package full name.
-v: jvm parameter list
Apply example:
C:\Users\yuhao.wang3>jps -l
11824 sun.tools.jps.Jps
9860 org.jetbrains.idea.maven.server.RemoteMavenServer
7960
jstat
Command is used to monitor virtual machines running various status information line tool. It can display local or remote virtual machine in the process of class loading, memory, garbage collection, JIT compiler and other operating data, there is no GUI graphical interface, provides only a text-only console server environment, it will be run on virtual positioning machine tool of choice for performance problems.
jstat [ option pid [interval[s|ms] [count]] ]
Suppose you want to query every 250 milliseconds garbage collection process conditions 9860, a total of five times inquiry, that the command should be:
C:\Users\yuhao.wang3>jstat -gc 9860 250 5
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
10752.0 10752.0 0.0 0.0 64512.0 867.6 76800.0 8207.2 23808.0 22909.2 3072.0 2769.6 6 0.049 4 0.209 0.258
10752.0 10752.0 0.0 0.0 64512.0 867.6 76800.0 8207.2 23808.0 22909.2 3072.0 2769.6 6 0.049 4 0.209 0.258
10752.0 10752.0 0.0 0.0 64512.0 867.6 76800.0 8207.2 23808.0 22909.2 3072.0 2769.6 6 0.049 4 0.209 0.258
10752.0 10752.0 0.0 0.0 64512.0 867.6 76800.0 8207.2 23808.0 22909.2 3072.0 2769.6 6 0.049 4 0.209 0.258
10752.0 10752.0 0.0 0.0 64512.0 867.6 76800.0 8207.2 23808.0 22909.2 3072.0 2769.6 6 0.049 4 0.209 0.258
- S0C: S0 represents the total size of the area
- S0U: S0 represents the size of the area has been used
jinfo
View and modify the parameters of the virtual machine, the command format:
jinfo [option] pid
jinfo -sysprops can review the parameters obtained by System.getProperties ()
jinfo-FLAG not explicitly specify the parameters of system defaults
jinfo -flags (note s) display parameters of the virtual machine
jinfo -flag + [parameters] parameter may be increased , but only by the java -XX: + PrintFlagsFinal -version and check out
Execute the example:
C:\Users\yuhao.wang3>jinfo -flags 9860
Attaching to process ID 9860, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.112-b15
Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=264241152 -XX:MaxHeapSize=805306368 -XX:MaxNewSize=268435456 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=88080384 -XX:OldSize=176160768 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -Djava.awt.headless=true -Didea.version==2018.3.2 -Xmx768m -Didea.maven.embedder.version=3.3.9 -Dfile.encoding=GBK
jmap
For raw heap dump snapshot (commonly referred to as heapdump or dump file). Jmap role is not just to obtain the dump file, it can finalize the query execution queue, Java heap and details of permanent generation, such as space usage, which is currently used for the collection and so on. And jinfo command, like, jmap there are many features in Windows platforms are limited, in addition to generate dump files for viewing and -dump options for each instance of the class, occupancy statistics -histo options are all operating systems provided, the other option can only be used under Linux / Solaris, the command format:
jmp [option] pid
Health piles of dump file:
C:\Users\yuhao.wang3>jmap -dump:live,format=b,file=heap.bin 9860
Dumping heap to C:\Users\yuhao.wang3\heap.bin ...
Heap dump file created
Jt
Virtual machine snapshots heap dump analysis tool
Analysis file just created:
C:\Users\yuhao.wang3>jhat C:\Users\yuhao.wang3\heap.bin
Reading from C:\Users\yuhao.wang3\heap.bin...
Dump file created Tue Jan 14 17:59:13 CST 2020
Snapshot read, resolving...
Resolving 151163 objects...
Chasing references, expect 30 dots..............................
Eliminating duplicate references..............................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
After the screen appears ". Server is ready" prompt, the user enters in the browser to http: // localhost: 7000 / can see the results, drag to the bottom, mainly to see "HeapHistogram".
jstack
jstack (Stack Trace for Java) command is used to generate a snapshot of the virtual machine thread the current time. Thread is a snapshot of the current method of virtual machines each executing thread stack collection, the main purpose of generating a snapshot of the thread is to locate the thread appears long pause, such as inter-thread deadlocks , infinite loop , requesting for a long time due to external resources are all waiting threads lead to long pause common cause, the command format:
jstack [option] pid
-F: when the request is not normal output in response to force the output thread stack
-l: In addition to the stack, display additional information about locks
-m: If a call to native method, then, may be displayed C / C ++ stack
Queries infinite loop example:
public class JstackDeadWhileTest {
public static void main(String[] args) {
int i = 1;
while (++i > 0) {
System.out.println(i);
}
}
}
C:\Users\yuhao.wang3>jps -l
18244 com.xiaolyuh.JstackDeadWhileTest
5444 org.jetbrains.jps.cmdline.Launcher
7960
10252 sun.tools.jps.Jps
17324 org.jetbrains.kotlin.daemon.KotlinCompileDaemon
C:\Users\yuhao.wang3>jstack -F 18244
Attaching to process ID 18244, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.112-b15
Deadlock Detection:
No deadlocks found.
Thread 14: (state = BLOCKED)
Thread 13: (state = BLOCKED)
Thread 12: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=143 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove() @bci=2, line=164 (Interpreted frame)
- java.lang.ref.Finalizer$FinalizerThread.run() @bci=36, line=209 (Interpreted frame)
Thread 11: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=502 (Interpreted frame)
- java.lang.ref.Reference.tryHandlePending(boolean) @bci=54, line=191 (Interpreted frame)
- java.lang.ref.Reference$ReferenceHandler.run() @bci=1, line=153 (Interpreted frame)
Thread 5: (state = IN_NATIVE)
- java.io.FileOutputStream.writeBytes(byte[], int, int, boolean) @bci=0 (Compiled frame; information may be imprecise)
- java.io.FileOutputStream.write(byte[], int, int) @bci=8, line=326 (Compiled frame)
- java.io.BufferedOutputStream.flushBuffer() @bci=20, line=82 (Compiled frame)
- java.io.BufferedOutputStream.flush() @bci=1, line=140 (Compiled frame)
- java.io.PrintStream.write(byte[], int, int) @bci=30, line=482 (Compiled frame)
- sun.nio.cs.StreamEncoder.writeBytes() @bci=120, line=221 (Compiled frame)
- sun.nio.cs.StreamEncoder.implFlushBuffer() @bci=11, line=291 (Compiled frame)
- sun.nio.cs.StreamEncoder.flushBuffer() @bci=15, line=104 (Compiled frame)
- java.io.OutputStreamWriter.flushBuffer() @bci=4, line=185 (Compiled frame)
- java.io.PrintStream.write(java.lang.String) @bci=27, line=527 (Compiled frame)
- java.io.PrintStream.print(int) @bci=5, line=597 (Compiled frame)
- java.io.PrintStream.println(int) @bci=6, line=736 (Compiled frame)
- com.xiaolyuh.JstackDeadWhileTest.main(java.lang.String[]) @bci=13, line=14 (Compiled frame)
Code () method for obtaining all the objects in the virtual machine threads with StackTraceElement getAllStackTraces java.lang.Thread class. Using this method can be completed through a simple few lines of code most of the functions jstack, we might call this method to be a page in the actual project administrator, you can always use a browser to view the thread stack.
Performance monitoring and troubleshooting tool
VisualVM: multi-in - Troubleshooting Tools
Direct operation command jvisualvm
can open VisualVM tool.
Plug-in installation
Go to this address to find the corresponding version of the plug-in address (HTTPS: //xxx/updates.xml.gz):
https://visualvm.github.io/pluginscenters.html
[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-K0KF0fLC-1579056995339) (https://upload-images.jianshu.io/upload_images/6464086-89b4c758c01ec499.png ? imageMogr2 / auto-orient / strip% 7CimageView2 / 2 / w / 1240)]