Java virtual machine knowledge - Tools

Command-line tool

1. jps

JVM Process Status Tool, display the virtual machine process.

Usage :jps [-q] [-mlvV]

Parameter Description

  • -q: Print the process ID
  • -l: print the fully qualified name of the class start
  • -m: main method parameters into a print start classes
  • -v: Prints the specified virtual machine parameters
  • -V: print the class name

Examples : jps,jps -l

2 jstat

Usage :jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Parameter Description

  • option: operating, is commonly used gcutilstatistical garbage collection situation.
  • -t: display the timestamp column
  • -h: Specifies the number of lines to display title
  • -vmid: Process ID
  • -interval: Time interval of each line of output
  • -count: Specifies the number of output lines

Examples : jstat -gcutil -h2 -t 15754 100 5representing the monitoring process ID 15754 garbage collection statistics, the output line every 100ms, total output five times, twice each output needs to re-export the title.

[root@root ~]# jstat -gcutil -h2 -t 15754 100 5
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
     11296830.0   0.00 100.00  21.80  25.80  98.41  96.33 113648 2500.825     0    0.000 2500.825
     11296830.2   0.00 100.00  21.80  25.80  98.41  96.33 113648 2500.825     0    0.000 2500.825
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
     11296830.3   0.00 100.00  21.80  25.80  98.41  96.33 113648 2500.825     0    0.000 2500.825
     11296830.4   0.00 100.00  21.80  25.80  98.41  96.33 113648 2500.825     0    0.000 2500.825
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
     11296830.5   0.00 100.00  21.80  25.80  98.41  96.33 113648 2500.825     0    0.000 2500.825

Description of output indicators

  • S0: survivor 0 Used Space accounting
  • S1: survivor 1 proportion used space
  • E: Eden District used space accounting
  • O: old's already accounted for by space
  • M: metadata is accounted for space
  • CCS: compression of space accounting
  • YGC: Mirror GC times
  • YGCT: Mirror GC time-consuming
  • FGC: Full GC times
  • FGCT: Full GC time-consuming
  • GCT: Total time consuming garbage collection

3. jinfo

JVM Configuration info, you can view real-time and real-time virtual machine to modify the parameters.

Usage :jinfo [option] <pid>

Parameter Description

  • option: Operation

    -flag value specified print VM arguments
    -flag [+ | -] Enables or disables the specified VM parameters
    -flag = modify VM parameter
    -flags print VM arguments
    -sysprops print Java System Configuration

  • pid: process ID

Examples : jinfo 15754,jinfo -flags 15754

4. jmap

JVM Memory Map, used to generate a stack dump file.

Usage :jmap [option] <pid>

Parameter Description

  • option: Operation

    heap: Java heap print Abstract
    histo [: live]: Print java object heap histogram; if the "live" option is specified, only objects in real-time computing
    dump: dump generation Snapshot

  • pid: process ID

Examples : jmap -heap 15754, jmap -histo:live 15754,jmap -dump:live,file=.\heap_dump.hprof 15754

5th jstack

The thread used to generate a snapshot of the current moment of the Java virtual machine for easy positioning thread long pause problems, such as deadlocks, infinite loop, waiting for a long time and so on.

Usage :jstack -F [-m] [-l] <pid>

Parameter Description

  • -F: force the printing stack
  • -m: while printing stack and Java native method
  • -l: print information about locks accessories
  • pid: process ID

Examples :jstack -l 15754

6. Jt

JVM Heap Analysis Tool, is used to analyze the log stack jmap generated, generates an HTML file. Usually we use visualization tools to analyze the log stack, such as MAT.

7. jcmd

JDK recommended jcmd alternative jstack, jinfo, jmap commands.

example

  • jcmd -l: Lists all the Java virtual machine.
  • jcmd 15754 help: lists the commands supported by the virtual machine.
  • jcmd 15754 PerfCounter.print: Get all relevant performance data.
  • jcmd 15754 GC.class_histogram

Visual monitoring tool

Common tools

  1. JConsole : monitoring tool that comes with the JDK
  2. jvisualvm : the JDK comes with monitoring tools, monitoring data show more than jconsole
  3. JMC : JDK also comes with monitoring tools, monitoring data show more than jvisualvm
  4. MAT : Memory Analyzer Tool, the Java virtual machine memory analysis tool that can quickly analyze log dump.

Guess you like

Origin www.linuxidc.com/Linux/2019-07/159651.htm