This article is from the “Deep Understanding of the Java Virtual Machine”, mainly for their own learning, used to record key points, convenient recall, review. Corresponding to chapter 4 of Understanding the Java Virtual Machine, common tools provided by the JDK.
Tools provided under JDK
1, JPS (JVM Process Status)
In the bin directory of the JDK, you can query LVMID.
Parameters:
-q Displays only the process number.
-m Prints the arguments passed to the main() function of the main class at startup.
-l Displays the full name of the main class and the path to the JAR package if the process executes it.
-v Displays JVM parameters when the VM is started
2. Jstat (JVM Statistics Monitoring Tool) Monitors VM Statistics
You can display the loading, memory, garbage collection, JIT compilation, and other running data of classes in a local or remote virtual machine process.
Format:
jstat option vmid [interval [count]]Copy the code
If the vmid is local, the vmid is the LVMID obtained in the JPS command. If the vmid is remote, the vmid is
[protocol:][//]lvmid[@localhost[:port]/servername]Copy the code
Interval indicates the monitoring interval, and count indicates the monitoring times.
Commonly used option:
-class Monitors class loading, number of unloads, total space, and time consumed by class loading
– GC Monitors Java heap status, usage of each section, gc times, GC time and other information
-gcutil indicates the pass-gc function. The data is displayed as a percentage.
– Gcnew Cenozoic GC
-gcold GC in old age
Example:
S0, S1: Survivor zone, Edent zone, O: elderly zone, YGC: MinorGC times, YGCT: MinorGC time, FGC: Full GC times, FGCT: Full GC time, GCT: total GC time
Jmap (Memory Map for Java) is used to generate heapdump snapshots (dump files).
In addition to dump file generation, you can also query Finalize execution queue and Java heap information.
-dump generates a Java heap storage snapshot in the following format
jmap -dump:format=b,file=filename 3039
Copy the code
– FinalizeInfo can only be used in Linux. It displays objects in the f-queue that are waiting to execute the Finalize method.
-heap is used only on Linux, and displays detailed Information about the Java heap.
The attached:
– XX: HeapDumpOnOutOfMemoryError parameter, make the virtual machine automatically generated when the OOM abnormal dump file
Jstack (Stack Trace for Java) Stack Trace tool
Thread snapshot (threaddump, Javacore file) used to generate current snapshot of the virtual machine
jstack [option] vmid
Parameters:
-f Forces the thread stack to be outputted if a normally outputted request is not answered.
-l Displays additional information about the lock in addition to the stack.
-m Displays the C/C++ stack if the local method is called.
Jconsole Java monitoring and administrative control
The startup command file is JavaHome/bin/jconsole, which can be used to monitor memory, CPU, threads, and deadlocks.
6. VisualVM integrated processing tool
The startup command file is JavaHome/bin/ jVisualVM