In-depth understanding of java virtual machine --- virtual machine tools jps and jstat (14)

 

jps-java process status

jps is similar to linux's ps command for viewing processes.

JPS 名称: jps - Java Virtual Machine Process Status Tool

Command usage:  jps [options] [hostid]

              options: command options, used to control the output format

              hostid: Specify a specific host, which can be an ip address and a domain name, or a specific protocol and port.

              [protocol:][[//]hostname][:port][/servername]

              

Function description: j ps is a process used to view the hotspot virtual machine that has access. When the hostid is not specified, it will view the local jvm process by default. Otherwise, it will view the jvm process on the machine with the specified hostid. The jstatd service must be enabled. jps can list jvm process lvmid, main class class name, main function parameters, jvm parameters, jar name and other information.

Command options and functions:

When no option is added, the VM identifier and simple class or jar name are listed by default. As follows:

 

-p : Only display the VM flag, not jar, class, main parameters and other information.

-m: Output the parameters passed in by the main function. The hello below is the parameters input from the command line when executing the program

-l: Output the full package name of the main class of the application or the full name of the jar.

-v: List jvm parameters, -Xms20m -Xmx50m are the jvm parameters specified by the startup program

-V: output jvm parameters specified by .hotsportrc or -XX:Flags=<filename>

-Joption: Pass arguments to the java lancher invoked by javac.

Example:

 

 jstat


To judge whether there is a memory problem in the JVM? How to judge whether JVM garbage collection is normal? The general top command basically cannot meet this requirement, because it mainly monitors the overall system resources, and it is difficult to locate the java application.

Jstat is a lightweight gadget that comes with the JDK. The full name is "Java Virtual Machine statistics monitoring tool", which is located in the bin directory of java. It mainly uses the built-in instructions of the JVM to monitor the resources and performance of Java applications in real-time on the command line, including Heap size and garbage collection status. monitoring. It can be seen that Jstat is a lightweight, JVM-specific tool that is very suitable. Due to the large JVM memory setting, the percentage change in the figure is less obvious

An extremely powerful tool for monitoring VM memory. Can be used to monitor various heap and non-heap sizes and their memory usage within VM memory.

The jstat tool is particularly powerful, with numerous options to view the usage of various parts of the heap in detail, as well as the number of loaded classes. When using, you need to add the process id of the viewing process and the selected parameters.

Execution: Execute jstat in cd $JAVA_HOME/bin, pay attention to the parameters after jstat.

1 Introduction

Jstat is used to monitor the HotSpot-based JVM and perform real-time command-line statistics on its heap usage. Using jstat, we can monitor the specified JVM as follows:

  • Loading and unloading of classes
  • View the capacity and usage of the new generation, old generation and metaSpace
  • View the garbage collection status of the new generation, old generation and metaSpace, including the number of garbage collections and the time taken for garbage collection
  • Check the capacity and allocation of the Eden area and Survior area in the new generation

    The jstat tool is particularly powerful. It has many options. By providing a variety of different monitoring dimensions, we can understand the current JVM heap usage from different dimensions. Check the usage of each part in the heap in detail. When using it, you must add the Java process number to be counted, optional different dimension parameters and optional statistical frequency parameters.

  • 2. Grammar

    write picture description here

    The following are the options supported by jdk1.8: 
    write picture description here

    The following are the options supported by versions below jdk1.8:

    write picture description here

    3 Examples

    jstat  -gc -h5  -t 26316 1s 20
    
    • 1
    • 2

    write picture description here

    -gc option 
    -h5 display the header every 5 lines 
    -t display the time interval from the virtual machine startup at the current time unit: second 
    26536 thread id 
    1s 1 second display once 
    20 total display 20 times

    4 Explanation of the header

    The real-name jdk1.7 and jdk1.8 are only one metaspace area apart, and the others are the same.

    header describe jdk version
    S0C The size of the current capacity of S0 in the Survivor space in the new generation (KB)  
    S1C The size of the current capacity of S1 in the Survivor space in the new generation (KB)  
    S0U The size of the S0 capacity used in the Survivor space in the new generation (KB)  
    S1U The size of the S1 capacity used in the Survivor space in the new generation (KB)  
    EC The size of the current capacity of Eden space (KB)  
    I The size of the Eden space capacity used (KB)  
    OC The size of the current capacity of the old space (KB)  
    WHERE The size of the old space used capacity (KB)  
    PC The size of the current capacity of the permanent space (KB) Below 1.8
    COULD The size of the permanent space used capacity (KB) Below 1.8
    MC The size of MeteSpace's current capacity (KB) 1.8 and above
    MU The size of the MeteSpace used capacity (KB) 1.8 and above
    CCSC Compressed class space size (KB) 1.8 and above
    CCSU Compressed class space size (KB) 1.8 and above
    YGC The number of times Young GC occurred from application startup to sampling  
    YGCT Time spent by Young GC from application startup to sampling time (seconds)  
    FGC The number of times Full GC occurred from application startup to sampling time  
    FGCT Full GC time from application startup to sampling time (seconds)  
    GCT The total time (in seconds) used for garbage collection from jvm startup to sampling, its value is equal to YGC+FGC  
     

Guess you like

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