JPS (JVM Process Status Tool)
Vm process status tool, which lists running VM processes and displays the names of the main execution classes (MainClass,main () classes) and the Local Virtual Machine Identifier (LVMID) of these processes.
- Command format:
jps[options][hostid]
- Parameters:
-q
Output only LVMID, omitting the main class name-m
: Prints the parameters passed to the main() function of the main class when the virtual machine process starts-l
: Prints the full name of the main class and the path to the jar if the process executes the jar package-v
: Displays THE JVM parameters for starting a VM process
Jstat (JVM Statistics Monitoring Tool)
Vm statistics monitoring tool A command line tool used to monitor THE RUNNING status of VMS. It can display runtime data such as classloading, memory, garbage collection, JIT compilation, etc. in local or remote virtual machine processes. On servers with no GUI graphical interface and only plain text console environment, it is the preferred tool for locating virtual machine performance problems at runtime.
- Command format:
jstat[option vmid[interval[s|ms][count]]]
- Note the following about VMID and LVMID in the command format: If the vm is a local PROCESS, the VMID and LVMID are the same. If it is a remote VM process, the format of the VMID should be:
Lvmid [@hostname[: port]/servername]
- Interval and count indicate the query interval and times. If these two parameters are omitted, the query is performed only once.
Jstat -gc 2764 250 20Copy the code
- Parameters: There are three main categories: class load, garbage collection, and runtime compile status
-class
: Monitors class loading, unload quantity, total space, and time consumed by class loading-gc
: Monitors Java heap health, including Eden area, 2 Survivor areas, old age, permanent generation capacity, used space, GC time total, etc-gccapacity
: Monitor content and-gc
Same, but the output focuses on the maximum and minimum space used by each region of the Java heap-gcutil
: Monitor content and-gc
Same, but the output focuses on the use of 100 percent of the total space-gccause
And:-gcutil
The same, but with additional output for the reason of the last GC-gcnew
Monitor the status of the New generation GC-gcnewcapacity
: Monitor content and-gcnew
Again, the output focuses on the maximum and minimum space used-gcold
: Monitor the status of old GC-gcoldcapacity
: Monitor content and-gcold
Again, the output focuses on the maximum and minimum space used-gcpermcapacity
: Outputs the maximum and minimum space used by the permanent generation-compiler
: Displays information about jIT-compiled methods and time consumption-printcompilation
: Outputs the jIT-compiled method
Jinfo (Configuration Info for Java)
Java configuration information tool to view and adjust VM parameters in real time.
- Command format:
jinfo[option]pid
- Parameters:
-flag
: Prints the value of the specified args parameter-flags
: Does not require the ARgs parameter and outputs the values of all JVM parameters-sysprops
: Output System properties, equivalent to system.getProperties ()
Jmap (Memory Map for Java)
Java Memory Mapping tool for generating heap dump snapshots (dump files)
- Several ways to get dump files
- Jmap command
- – XX: + HeapDumpOnOutOfMemoryError parameters, can make a virtual machine after OOM anomalies appear automatically generate the dump file
- -xx: +HeapDumpOnCtrlBreak If the HeapDumpOnCtrlBreak parameter is used, press [Ctrl]+[Break] to make the VM generate dump files
- Passed in Linux
Kill-3
Dump files can also be retrieved by sending process exit signals
- Command format:
jmap[option]vmid
- Parameters:
-dump
: Generates a heap dump snapshot-finalizerinfo
: Displays objects in the f-Queue that are waiting for the Finalizer thread to execute the Finalizer method-heap
: Displays the Java heap details-histo
: Displays statistics about objects in the heap-permstat
: Displays permanent generation memory status using CLassLoader as the statistical caliber-F
: If -dump does not respond, a dump snapshot is forcibly generated
Jhat (JVM Heap Analysis Tool)
Used with jMAP to analyze heap dump snapshots generated by Jmap. Jhat comes with a mini-HTTP /HTML server that generates analysis of dump files for viewing in a browser.
- Command format:
jhat [dumpfile]
- This command is not recommended for two reasons:
- Dump files are not directly analyzed on the server, wasting server resources.
- It is recommended to use a professional visual analysis tool, such as VisualVM
Jstack (Stack Trace for Java)
A Java stack trace tool that generates a thread snapshot of the virtual machine at the current time.
A thread snapshot is a collection of method stacks that are being executed by each thread in a VM. The purpose of a thread snapshot is to locate the cause of a thread’s long pause, such as deadlocks, loops, and long waits caused by requests for external resources.
Using jStack to look at the call stack of each thread when it pauses, you can see what unresponsive threads are doing in the background or waiting for resources.
- Command format:
jstack[option]vmid
- Parameters:
-F
: Forces the output thread stack when a normally output request is not responded to-l
: Displays additional information about the lock in addition to the stack-m
C/C++ stack can be displayed if a local method is called
- In JDK 1.5,
java.lang.Thread
Class has a new onegetAllStackTraces()
The StackTraceElement () method is used to get StackTraceElement objects for all threads in the virtual machine.