学习笔记——JVM性能调优之 jstat

jstat

jstat(JVM statistics Monitoring)是用于监视虚拟机运行时状态信息的命令,它可以显示出虚拟机进程中的类装载、内存、垃圾收集、JIT编译等运行数据。

官方文档链接地址:https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html

命令格式:

jstat [ generalOption | outputOptions vmid [ interval[s|ms] [ count ] ]

 

generalOption :常规命令参数(-help或-options),如果指定则不能添加任何其他选项或参数。

outputOptions : 命令参数,可加 -t,-h 和 -J 选项。

vimid: 虚拟机进程ID

interval:采样间隔,单位为秒(s)或毫秒(ms),默认为毫秒(ms)。

count:显示次数

 

outputOptions参数:

  • -class 显示有关类加载器行为的统计信息。(Displays statistics about the behavior of the class loader.)

    • Loaded:已加载的类(Class)数量。

    • Bytes:加载的类(Class)大小。(单位:KB)

    • Unloaded:卸载的类(Class)数量。

    • Bytes:卸载的类(Class)大小。(单位:KB)

    • Time:执行时间。

 

  • -compiler 显示有关Java HotSpot VM即时编译器行为的统计信息。(Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.)

    • Compiled:执行的编译任务数

    • Failed:编译任务失败数量

    • Invalid:无效的编译任务数

    • Time:执行编译任务花费时间

    • FailedType:失败类型

    • FailedMethod:失败的方法

 

  • -gc 显示有关垃圾收集堆行为的统计信息。(Displays statistics about the behavior of the garbage collected heap.)

 

 

  • -gccapacity 包含部分-gc内容,同时还会显示 各区域使用到的最大、最小空间。(Displays statistics about the capacities of the generations and their corresponding spaces.)

NGCMN: 年轻代最小容量   Minimum new generation capacity (kB).
NGCMX: 年轻代最大容量   Maximum new generation capacity (kB).
NGC:   当前年轻代容量   Current new generation capacity (kB).
OGCMN: 老年代最小容量   Minimum old generation capacity (kB).
OGCMX: 老年代最大容量   Maximum old generation capacity (kB).
OGC:   当前老年代容量   Current old generation capacity (kB).
MCMN:  元空间区最小容量 Minimum metaspace capacity (kB).
MCMX:  元空间区最大容量 Maximum metaspace capacity (kB).
CCSMN: 压缩类空间最小容量  Compressed class space minimum capacity (kB).
CCSMX: 压缩类空间最大容量  Compressed class space maximum capacity (kB).
 
  • -gcutil 显示各区域已使用空间占总空间的百分比。(Displays a summary about garbage collection statistics.)

S0:survivor0(第一个幸存区空间)空间使用率  
S1:survivor1(第二个幸存区空间)空间使用率 
E: Eden空间 空间使用率
O: 老年代  空间使用率
M: 元空间  空间使用率
CCS:压缩类空间空间使用率  Compressed class space utilization as a percentage.
YGC:年轻代垃圾回收次数  Number of young generation GC events.
YGCT:年轻代垃圾回收消耗时间
FGC:老年代垃圾回收次数
FGCT:老年代垃圾回收消耗时间
GCT: 垃圾回收总消耗时间

 

  • -gccause 同-gcutil,增加了两次垃圾回收的触发原因。 (Displays a summary about garbage collection statistics (same as -gcutil), with the cause of the last and current (when applicable) garbage collection events.)

LGCC:上次垃圾回收的原因  Cause of last garbage collection
GCC: 当前垃圾回收的原因  Cause of current garbage collection   
      Allocation Failure:表明引起GC的原因是因为在年轻代中没有足够的空间能够存储新的数据了。

 

  • -gcnew 统计年轻代垃圾回收信息 (Displays statistics of the behavior of the new generation.)

TT: 对象在新生代经历过垃圾回收的次数    Tenuring threshold.
MTT:对象在新生代可经历垃圾回收的最大值  Maximum tenuring threshold.
DSS:所需survivor区域大小        Desired survivor size (kB).

 

  • -gcnewcapacity 显示新生代最大、最小内存空间统计 (Displays statistics about the sizes of the new generations and its corresponding spaces.)

ECMX:最大Eden空间容量   Maximum eden space capacity (kB).

 

  • -gcold 统计老年代垃圾回收信息 (Displays statistics about the behavior of the old generation and metaspace statistics.)

 

  • -gcoldcapacity 显示老年代最大、最小内存空间统计 (Displays statistics about the sizes of the old generation.)

 

  • -gcmetacapacity 显示元空间最大、最小内存空间统计 (Displays statistics about the sizes of the metaspace.)

 

  • -printcompilation JVM编译方法统计 (Displays Java HotSpot VM compilation method statistics.)

Compiled:最近编译的方法执行的编译任务数
Size:    最近编译的方法的字节码数量
Type:    最近编译的方法的编译类型
Method:  标识最近编译的方法的类名和方法名。类名使用斜杠(/)代替点(。)作为名称空间分隔符。
          方法名称是指定类中的方法。这两个字段的格式与HotSpot-XX:+PrintCompilation选项一致。

 

 

 

如果有错误或者更优化的解决方案,欢迎大家在评论区留言探讨。

也可以给我的个人公众号私信留言。

posted @ 2021-02-04 16:41  殇灬央  阅读(211)  评论(0编辑  收藏  举报
/* */