[Study notes] in-depth understanding of the Java Virtual Machine Chapter IV VM performance monitoring and troubleshooting tool

jps(jvm process status tool)

Lists the virtual machines running processes and displays (Class Main Class, main () function resides) virtual machine executes the main class name and local processes these virtual machines unique ID (Local Virtual Machine
Identifier, LVMID)

jps -l: run the main class full name or the name of the jar package

 

 

 jps -m: incoming primary parameter class (args) runtime

 

jps -v: virtual machine parameters

 

 

 jstat(JVM statistics monitoring tool)

Command is used to monitor virtual machines running various status information line tool. It can be displayed locally or remotely [1] virtual machine in the process of class loading, memory, garbage collection, JIT compiler and other operating data

jstat -gcutil process ID:

 

 

 jstat -gcutil time interval (ms) Monitoring times:

 

 

 

Query results showed that: the new generation Eden District this server (E, expressed Eden) used 58.56 percent of the space, two Survivor areas (S0, S1, represents Survivor0, Survivor1) 100% 0%, respectively, years old (O representing Old) and meta-space (metaspace) ( JDK7 has been removed permanently generations ) respectively, using 76.79 percent and 93.35 percent of the space, compression of space (CCS) accounted for 88.94%, since the program runs Minor GC (YGC were expressed Young GC) 536 times, the total time 4.614 seconds, occurs FullGC (FGC, expressed Full GC) 34 times, total elapsed time Full GC (FGCT, represents Full GC time) is 2.293 seconds, all GC total elapsed time (GCT, represents GC Time) is 6.907 seconds.

 jinfo(configuration info for java)

作用是实时地查看和调整虚拟机各项参数。使用jps命令的-v参数可以查看虚拟机启动时显式指定的参数列表,但如果想知道未被显式指定的参数的系统默认值,除了去找资料外,就只能使用jinfo的-flag选项进行查询了。

jinfo -flag UseG1GC 12620:(查询是否使用G1GC,+号表示使用,-号表示不使用)

 

 

 

 

 

 

 jmap(Memory Map for Java)

用于生成堆转储快照(一般称为heapdump或dump文件)。

jmap的作用并不仅仅是为了获取dump文件,它还可以查询finalize执行队列、Java堆和永久代的详细信息,如空间使用率、当前用的是哪种收集器等。和jinfo命令一样,jmap有不少功能在Windows平台下都是受限的,除了生成dump文件的-dump选项和用于查看每个类的实例、空间占用统计的-histo选项在所有操作系统都提供之外,其余选项都只能在Linux/Solaris下使用。

jmap -dump:format=b,file=d:\a.bin 12620:

 

 

 

jmap -histo:live 12620:显示堆中存活的内容

 

jhat(JVM Heap Analysis Tool)

与jmap搭配使用,来分析jmap生成的堆转储快照。

先用jmap dump一个文件,然后jhat d:\a.bin:

 

 

 然后输入http://localhost:7000/,即可看到分析结果。

分析过程占用CPU和内存非常高。

jstack(Stack Trace for Java)

用于生成虚拟机当前时刻的线程快照(一般称为threaddump或者javacore文件)。线程快照就是当前虚拟机内每一条线程正在执行的方法堆栈的集合,生成线程快照的主要目的是定位线程出现长时间停顿的原因,如线程间死锁、死循环、请求外部资源导致的长时间等待等都是导致线程长时间停顿的常见原因。线程出现停顿的时候通过jstack来查看各个线程的调用堆栈,就可以知道没有响应的线程到底在后台做些什么事情,或者等待着什么资源。

jstack -l:除堆栈外,显示关于锁的附加信息。

 

 

 jstack -F 12620:当正常输出的请求不被响应时,强制输出线程堆栈

 jstack -m 12620:如果调用到本地方法的话,可以显示C/C++的堆栈

可视化工具——jconsole

命令行输入jconsole即可,可以内存监控、线程监控、检查死锁等。

Guess you like

Origin www.cnblogs.com/mcq1999/p/12128019.html