Virtual Machine Performance Monitoring and Troubleshooting Tools

 

  The JDK development team chose Java to implement these monitoring, and when the application is deployed to the production environment, it may be limited whether it can directly contact the physical server or remotely Telnet to the server. With the help of the interfaces in the tools.jar class library, powerful monitoring and analysis functions can be implemented directly in the application.

name main function
jps JVM Process Status Tool, displays all HotSpot virtual machine processes in the specified system, and displays the name of the virtual machine executing Zhu Lei and the unique ID of the local virtual machine of these processes
jstat JVM Statistics Monitoring Tool for running data of all aspects of the HotSpot virtual machine on the phone
jinfo Configuration Info for Java, only shows the virtual machine configuration galaxy
jmap Memory Map for Java, which generates a memory dump snapshot of the virtual machine
jhat JVM Heap Dump Browser, used to analyze heapdump files, it will build an HTTP/HTML server, allowing users to view the analysis results on the browser
jstack Stack Trace for Java, showing a thread snapshot of the virtual machine

 

 

 

 

 

  jps virtual machine process status tool

    jsp (JVM Process Status Tool) can list running virtual machine processes, and display the virtual machine execution main class name and the local virtual machine unique ID (Local Virtual Machine Identifier, LVMID) of these processes

    Command format jps [options] [hostid]

    jps can query the status of the remote virtual machine process with the RMI service enabled through the RMI protocol. The hostid is the host name registered in the RMI registry.

options comment
-q Only output the LVMID, omitting the name of the main class
-m Output the parameters passed to the main class main() function when the virtual machine Splendid Huacheng can start
-l Output the full name of the main class, if the process executes the Jar package, output the Jar package
-v Output the JVM parameters when the virtual machine process starts

 

 

 

 

 

  jstat virtual machine statistics monitoring tool

    jstat (JVM Statistics-Monitoring Tool) is a command-line tool used to monitor various running status information of virtual machines. It can display running data such as class loading, memory, garbage collection, JIT compilation, etc. in the local or remote virtual machine process.

    Command format jstat [ option vmid [ interval [s|ms] [count] ] ] For the VMID and LVMID in the command format: if it is a local virtual machine process, VMID and LVMID are the same, if it is a remote virtual machine process, then the format of VMID is [protocol:][//_]lvmid[@hostname[:port]/servername]. interval and count represent the query interval and times, respectively. If there are two parameters of winning rate, the description can only be queried once. option represents the virtual machine information that the user wants to query, which is mainly divided into three categories: class loading, garbage collection, and runtime compilation status.

    eg: jstat -gc 2764 250 20 //250ms to query the garbage collection status of process 2764 once, a total of 20 queries

option comment
-class Monitors the number of class loads, unloads, total space and time spent in class loading
-gc Monitor Java heap status, including Eden area, two Survivor areas, the capacity of old generation, permanent generation, etc., used space, total GC time and other information
-gccapacity The monitoring content is basically the same as -gc, but the output mainly focuses on the maximum and minimum space used by each area of ​​the Java heap
-gcutil The monitoring content is basically the same as -gc, but the output mainly focuses on the used space as a percentage of the total space
-gccause  Same as -gcutil, but additionally output the reason for the last GC
-gcnew Monitor young generation GC status
-gcnewcapacity The monitoring content is basically the same as -gcnew, and the output mainly focuses on the maximum and minimum space used
-gcold Monitor old generation GC status
-gcoldcapacity The monitoring content is basically the same as -gcold, and the output mainly focuses on the maximum and minimum space used
-gcpermcapacity Output the maximum and minimum space used by the permanent generation
-compiler Output the compiled method, time-consuming and other information during JFT compilation
-printcompilation Output methods that have been JIT compiled

 

 

     

  

 

 

 

 

 

    E represents the percentage of space used by Eden, and S0 and S1 represent the percentage of space occupied by Survivor0 and Survivor1, respectively. O represents the percentage occupied by the Old generation, and P represents the percentage of space occupied by the Permanent generation. YGC represents the number of occurrences of Minor GC (Young GC), and YGCT represents the time taken for Young GC to occur. FGC represents the number of Full GC occurrences, and FGCT represents the duration of Full GC occurrences. GCT stands for GC Time, the total time taken for GC to occur.

 

  jinfo: Java configuration information tool

    The role of jinfo (Configuration Info for Java) is to view and adjust various parameters of the virtual machine in real time. Use the -v parameter of the jps command to view a list of parameters explicitly specified when the virtual machine is started.

    Command format jinfo [option] pid

    The -flag option of jinfo can query the system default value of parameters that are not explicitly specified. Use java -XX:+PrintFlagsFinal to view the default value of the parameter, or use the -sysprops option to print the contents of the System.getProperties() of the virtual machine process.

 

  jmap: Java Memory Mapping Tool

    The jmap (Memory Map for Java) command is used to generate heap dump snapshots (commonly known as heapdump or dump files). If the jmap command is not applicable, you can use -XX:+HeapDumpOnOutOfMemoryError to make the virtual machine automatically generate a dump file after an OOM exception occurs. Through the -XX:+HeapDumpOnCtrlBreak parameter, you can use Ctrl+Break to make the virtual machine generate a dump file. Under Linux, you can also get the dump file by sending the process to exit using the Kill -3 command. jmap can also query the finalize execution queue, Java heap and permanent generation details.

    jmap command format jmap [option] vmid

option comment
-dump Generate a Java heap dump snapshot in the format: -dump:[live, ]format=b, file=<filename>. The live sub-parameter indicates whether only the surviving objects are dumped
-finalizerinfo Displays objects in the F-Queue waiting for the Finalizer thread to execute the finalizer method. Only valid under Linux/Solaris platform
-heap Display Java heap details, such as which collector to use, parameter configuration, generation status, etc.
-histo Displays statistics of objects in the heap, including class, number of strengths, and total capacity
-permstat Display the permanent generation memory status with ClassLoader as the statistical caliber
-F When the virtual machine process heap -dump option does not respond, you can use this option to force a dump snapshot

 

 

 

 

 

  jhat virtual machine heap snapshot analysis tool

    jhat is used in conjunction with jmap to analyze heap dump snapshots generated by jmap. jhat has a built-in miniature HTTP/HTML server. After generating the analysis result of the dump file, it can be viewed in the browser. But in actual work, the jhat command is generally not used to analyze the dump file. There are two main reasons: generally, the server that is not deployed on the application program directly analyzes the dump file. Even if it is possible, the dump file will be copied to other machines for analysis, because analysis is a time-consuming and hardware resource-consuming process; One reason is that the analysis function of jhat is relatively simple, and VisualVM, or Memory Anaylzer and HeapAnalyzer are generally used.

 

  jstack Java stack tracer

    jstack (Stack Trace for Java) is used to generate a thread snapshot of the current moment of the virtual machine, usually a threaddump or javacore file. A thread snapshot is a collection of method stacks that are being executed by each thread in the current virtual machine. The main purpose of generating a thread snapshot is to locate the cause of the thread's long pause, such as deadlock and infinite loop.

  Command format jstack [option] vmid

option comment
-F When the normal output request is not answered, force the output thread stack
-l Displays additional information about locks in addition to the stack
-m If a native method is called, the C/C++ stack can be displayed

 

  

 

 

  HSDIS: JIT generated code disassembly

    HSDIS can be called by HotSpot's -XX:+PrintAssembly instruction to restore dynamically generated native code to assembly code output, and also generate a large number of comments.

 

  VisualVM

    Visual VM can do: display virtual machine process and process configuration, environment information (jps, jinfo); monitor application CPU, GC, heap, method area and thread information (jstat, jstack); dump and analyze heap transfer Store snapshots (jmap, jhat); method-level program running performance analysis to find out the method that is called the most and has the longest running time; offline program snapshot: the runtime configuration of the mobile program, thread dump, memory dump and other information to create a snapshot , you can send the snapshot to the developer for bug feedback.

    There are two ways to generate a dump file in Visual VM: click the application node in the application window, then select heap dump; double-click the application node in the application window to open the application tab, then in the "Monitoring" tab Click on "heap dump". After the dump file is generated, the application tab will add a subnode starting with [heapdump] under the application of the heap, and the dump snapshot will be opened in the homepage tab.

    On the Profiler tab, Visual VM provides method-level CPU execution time analysis and memory analysis during program execution. Profiling analysis will have a greater impact on program performance.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325157287&siteId=291194637