李锋镝的博客

  • 首页
  • 时间轴
  • 说说
  • 每日心情
  • Now
  • 系列文章
  • 论坛
  • 左邻右舍
    • 左邻右舍
    • 博友圈
  • 留言
    • 留言
    • 走心评论
  • 关于
    • 关于本站
    • 网站地图
    • 网站统计
    • 另一个网站
    • 我的导航站
    • 赞助
  • 🚇开往
!Destiny
惟坚韧者始能遂其志
  1. 首页
  2. 原创
  3. 正文

jstat命令使用(JDK1.8)

2020年8月12日 约 3,390 字12 分钟 174 0 0
本文最后更新于 2021年5月8日,距今已 1955 天,其中的信息可能已经发生变化,请注意甄别。

概述

jstat命令可以查看堆内存各部分的使用量,以及加载类的数量。命令的格式如下:

jstat [-命令选项] [vmid] [间隔时间/默认单位是ms毫秒] [查询次数]

注意:jdk版本是jdk1.8

详述

详细格式可以输入jstat -help命令查看:

[root@root ~]# jstat -help
Usage: jstat -help|-options
       jstat -

option选项有哪些,可以使用jstat -options命令查看:

[root@infra2-test-k8s ~]# jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

option参数说明:

-class: 类加载的行为统计 Displays statistics about the behavior of the class loader.
-compiler:  HotSpt JIT编译器行为统计 Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.
-gc:    垃圾回收堆的行为统计。Displays statistics about the behavior of the garbage collected heap.
-gccapacity:    各个垃圾回收代容量(young,old,meta)和他们相应的空间统计。isplays statistics about the capacities of the generations and their corresponding spaces.
-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.
-gcmetacapacity:    统计元空间使用情况 Displays statistics about the sizes of the metaspace.
-gcnew: 显示新生代统计信息 Displays statistics of the behavior of the new generation.
-gcnewcapacity: 统计新生代及内存使用情况 Displays statistics about the sizes of the new generations and its corresponding spaces.
-gcold: 统计老年代和元空间使用情况 Displays statistics about the behavior of the old generation and metaspace statistics.
-gcoldcapacity: 统计老年代内存使用情况 Displays statistics about the sizes of the old generation.
-gcutil:    显示各个各代内存使用百分比 Displays a summary about garbage collection statistics.
-printcompilation:  Hotspot方法编译统计情况 Displays Java HotSpot VM compilation method statistics.

jstat命令简单使用及说明(后面的英文为官方文档原文)

为了方便直观,我们直接使用jps命令,查看所有的Java进程以及进程id:

[root@root ~]# jps -l
1 org.apache.catalina.startup.Bootstrap
17546 sun.tools.jps.Jps

jps命令格式:jps [options ] [ hostid ]

  [options]选项 :
  -q:仅输出VM标识符,不包括classname,jar name,arguments in main method 
  -m:输出main method的参数 
  -l:输出完全的包名,应用主类名,jar的完全路径名 
  -v:输出jvm参数 
  -V:输出通过flag文件传递到JVM中的参数(.hotspotrc文件或-XX:Flags=所指定的文件 
  -Joption:传递参数到vm,例如:-J-Xms512m

jstat -class : 类加载的行为统计 Class loader statistics.

[root@root ~]# jstat -class 1
Loaded  Bytes  Unloaded  Bytes     Time   
 24301 45978.0      277   411.9      44.91

参数说明:

Loaded :加载class的数量 Number of classes loaded.

Bytes : 加载class的大小(单位KB)Number of kBs loaded.

Unloaded :卸载class的数量 Number of classes unloaded.

Bytes: 卸载class的大小(单位KB) Number of Kbytes unloaded.

Time : 加载和卸载class所耗费的时间 Time spent performing class loading and unloading operations.

jstat -compiler :HotSpt JIT编译器行为统计 Java HotSpot VM Just-in-Time compiler statistics.

[root@root ~]# jstat -compiler 1
Compiled Failed Invalid   Time   FailedType FailedMethod
   31073      3       0   182.63          1 com/mysql/jdbc/AbandonedConnectionCleanupThread run

参数说明:

Compiled :编译成功数 Number of compilation tasks performed.

Failed : 编译失败数 Number of compilations tasks failed.

Invalid : 无效数量 Number of compilation tasks that were invalidated.

Time:编译时间 Time spent performing compilation tasks.

FailedType : 最后一次编译失效类型 Compile type of the last failed compilation.

FailedMethod :最后一次编译失效的方法 Class name and method of the last failed compilation.

jstat -gc:垃圾回收堆的行为统计 Garbage-collected heap statistics.

[root@root ~]# jstat -gc 1
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
17472.0 17472.0  0.0   1248.6 139776.0  7359.2   349568.0   233485.7  149632.0 144590.5 16768.0 15863.7   1119   11.856  11      2.871   14.727

参数说明:

S0C : 第一个幸存区的总容量(KB)Current survivor space 0 capacity (kB).

S1C : 第二个幸存区的总容量(KB)Current survivor space 1 capacity (kB).

S0U : 第一个幸存区已使用的容量(KB)Survivor space 0 utilization (kB).

S1U : 第二个幸存区已使用的容量(KB)Survivor space 1 utilization (kB).

EC : 伊甸区的总容量(KB)Current eden space capacity (kB).

EU : 伊甸区已使用容量(KB)Eden space utilization (kB).

OC : 老年区的总容量(KB)Current old space capacity (kB).

OU:老年代使用大小(KB)Old space utilization (kB).

MC : 元空间的总容量(KB)Metaspace capacity (kB).

MU : 元空间已使用容量(KB)Metacspace utilization (kB).

CCSC : 压缩类空间总容量(KB)Compressed class space capacity (kB).

CCSU : 压缩类空间已使用总容量(KB)Compressed class space used (kB).

: 新生代GC次数Number of young generation garbage collection events.

YGCT :新生代GC总耗费时间Young generation garbage collection time.

FGC : FullGC次数Number of full GC events.

FGCT : FullGC总耗费时间Full garbage collection time.

GCT : GC总耗费时间Total garbage collection time.

jstat -gccapacity : 各个回收区内存情况 Memory pool generation and space capacities.

[root@root ~]# jstat -gccapacity 1
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC 
 10880.0 174720.0 174720.0 17472.0 17472.0 139776.0    21888.0   349568.0   349568.0   349568.0      0.0 1181696.0 149632.0      0.0 1048576.0  16768.0   1119    11

NGCMN:新生代最小容量 Minimum new generation capacity (kB).

NGCMX:新生代最大容量 Maximum new generation capacity (kB).

NGC:当前新生代容量 Current new generation capacity (kB).

S0C:第一个幸存区大小 Current survivor space 0 capacity (kB).

S1C:第二个幸存区的大小 Current survivor space 1 capacity (kB).

EC:伊甸园区的大小 Current eden space capacity (kB).

OGCMN:老年代最小容量 Minimum old generation capacity (kB).

OGCMX:老年代最大容量 Maximum old generation capacity (kB).

OGC:当前老年代容量 Current old generation capacity (kB).

OC:当前老年代大小 Current old space capacity (kB).

MCMN:最小元数据容量 Minimum metaspace capacity (kB).

MCMX:最大元数据容量 Maximum metaspace capacity (kB).

MC:当前元数据空间大小 Metaspace capacity (kB).

CCSMN:最小压缩类空间大小 Compressed class space minimum capacity (kB).

CCSMX:最大压缩类空间大小 Compressed class space maximum capacity (kB).

CCSC:当前压缩类空间大小 Compressed class space capacity (kB).

YGC:年轻代gc次数 Number of young generation GC events.

FGC:老年代GC(FullGC)次数 Number of full GC events.

jstat -gccause :垃圾收集统计概述 This option displays the same summary of garbage collection statistics as the -gcutil option, but includes the causes of the last garbage collection event and (when applicable) the current garbage collection event. In addition to the columns listed for -gcutil, this option adds the following columns.

[root@root ~]# jstat -gccause 1
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC                 
  6.67   0.00  90.76  66.79  96.66  94.62   1130   11.949    11    2.871   14.820 Allocation Failure   No GC 

S0 :第一幸存区已使用空间百分比 Survivor space 0 utilization as a percentage of the space's current capacity.

S1 :第二幸存区已使用空间百分比 Survivor space 1 utilization as a percentage of the space's current capacity.

E : 伊甸区已使用空间百分比 Eden space utilization as a percentage of the space's current capacity.

O : 老年区已使用空间百分比 Old space utilization as a percentage of the space's current capacity.

M : 元空间使用百分比 Metaspace utilization as a percentage of the space's current capacity.

CCS : 压缩类空间使用百分比 Compressed class space utilization as a percentage.

YGC : 新生代GC次数 Number of young generation GC events.

FGC : 老年代GC次数 Number of full GC events.

LGCC :最近一次GC原因 Cause of last garbage collection

GCC : 当前GC原因 Cause of current garbage collection

jstat -gcnew : 显示新生代统计信息 New generation statistics.

[root@root ~]# jstat -gcnew 1
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
17472.0 17472.0    0.0 1350.4 15  15 8736.0 139776.0  73826.1   1131   11.957

S0C : 第一幸存区总空间大小(KB)Current survivor space 0 capacity (kB).

S1C : 第二幸存区总空间大小(KB)Current survivor space 1 capacity (kB).

S0U : 第一幸存区已使用空间大小(KB)Survivor space 0 utilization (kB).

S1U : 第二幸存区已使用空间大小(KB)Survivor space 1 utilization (kB).

TT : 提升阈值 Tenuring threshold.

MTT : 最大阈值 Maximum tenuring threshold.

DSS : 预期survivor区域大小 (KB) Desired survivor size (kB).

EC : 伊甸区总空间大小(KB)Current eden space capacity (kB).

EU : 伊甸区已使用空间大小(KB)Eden space utilization (kB).

YGC:年轻代gc次数 Number of young generation GC events.

YGCT :新生代GC总耗费时间 Young generation garbage collection time.

jstat -gcnewcapacity : 统计新生代及内存使用情况 New generation space size statistics.

[root@root ~]# jstat -gcnewcapacity 1
  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC 
   10880.0   174720.0   174720.0  17472.0  17472.0  17472.0  17472.0   139776.0   139776.0  1131    11

NGCMN : 新生代最小空间大小(KB)Minimum new generation capacity (kB).

NGCMX : 新生代最大空间大小(KB)Maximum new generation capacity (kB).

NGC : 当前新生代空间大小(KB) Current new generation capacity (kB).

S0CMX : 第一幸存区最大空间大小(KB)Maximum survivor space 0 capacity (kB).

S0C : 第一幸存区当前空间大小(KB)Current survivor space 0 capacity (kB).

S1CMX : 第二幸存区最大空间大小(KB)Maximum survivor space 1 capacity (kB).

S1C : 第二幸存区当前空间大小(KB)Current survivor space 1 capacity (kB).

ECMX : 伊甸区最大空间大小(KB)Maximum eden space capacity (kB).

EC : 伊甸区当前空间大小(KB)Current eden space capacity (kB).

YGC : 新生代GC次数 Number of young generation GC events.

FGC : 老年代GC次数 Number of full GC events.

jstat -gcold : 统计老年代和元空间使用情况 Old generation and metaspace behavior statistics.

[root@root ~]# jstat -gcold 1
   MC       MU      CCSC     CCSU       OC          OU       YGC    FGC    FGCT     GCT   
149632.0 144638.0  16768.0  15866.4    349568.0    233488.9   1132    11    2.871   14.841

MC : 元空间总大小(KB)Metaspace capacity (kB).

MU : 元空间已使用大小(KB)Metaspace utilization (kB).

CCSC : 压缩类空间总大小(KB) Compressed class space capacity (kB).

CCSU : 压缩类空间已使用大小(KB)Compressed class space used (kB).

OC : 老年区空间总大小(KB) Current old space capacity (kB).

OU : 老年区已使用大小(KB)Old space utilization (kB).

YGC : 新生代GC次数 Number of young generation GC events.

FGC : 老年代GC次数 Number of full GC events.

FGCT : 老年代GC总耗时 Full garbage collection time.

GCT : GC总耗时 Total garbage collection time.

jstat -gcoldcapacity : 统计老年代内存使用情况 Old generation size statistics.

[root@root ~]# jstat -gcoldcapacity 1
   OGCMN       OGCMX        OGC         OC       YGC   FGC    FGCT     GCT   
    21888.0    349568.0    349568.0    349568.0  1132    11    2.871   14.841

OGCMN :老年区占用最小空间(KB)Minimum old generation capacity (kB).

OGCMX : 老年区占用最大空间(KB)Maximum old generation capacity (kB).

OGC : 当前老年区空间(KB)Current old generation capacity (kB).

OC : 当前老年区空间(KB)Current old space capacity (kB).

YGC :新生代GC次数 Number of young generation GC events.

FGC : 老年代GC次数 Number of full GC events.

FGCT : 老年代GC总耗时 Full garbage collection time.

GCT : GC总耗时 Total garbage collection time.

gc -gcmetacapacity :元空间使用情况 Metaspace size statistics.

[root@root ~]# jstat -gcmetacapacity 1
   MCMN       MCMX        MC       CCSMN      CCSMX       CCSC     YGC   FGC    FGCT     GCT   
       0.0  1181696.0   149632.0        0.0  1048576.0    16768.0  1131    11    2.871   14.828

MCMN : 元空间最小空间大小(KB) Minimum metaspace capacity (kB).

MCMX : 元空间最大空间大小(KB)Maximum metaspace capacity (kB).

MC : 元空间当前空间大小(KB)Metaspace capacity (kB).

CCSMN : 压缩类空间最小空间大小(KB) Compressed class space minimum capacity (kB).

CCSMX : 压缩类空间最大空间大小(KB) Compressed class space maximum capacity (kB).

CCSC : 压缩类空间当前空间大小(KB)Compressed class space capacity (kB).

YGC : 新生代GC次数 Number of young generation GC events.

FGC : 老年代GC次数 Number of full GC events.

FGCT: 老年代GC耗费时间 Full garbage collection time.

GCT : GC总耗费时间 Total garbage collection time.

jstat -gcutil : 垃圾回收统计 Summary of garbage collection statistics.

[root@root ~]# jstat -gcutil 1
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
  6.68   0.00  39.54  66.79  96.66  94.62   1132   11.970    11    2.871   14.841

S0 :第一幸存区已使用空间百分比 Survivor space 0 utilization as a percentage of the space's current capacity.

S1 : 第二幸存区已使用空间百分比 Survivor space 1 utilization as a percentage of the space's current capacity.

E : 伊甸区已使用空间百分比 Eden space utilization as a percentage of the space's current capacity.

O : 老年区已使用空间百分比 Old space utilization as a percentage of the space's current capacity.

M : 元空间使用百分比 Metaspace utilization as a percentage of the space's current capacity.

CCS : 压缩类空间使用百分比 Compressed class space utilization as a percentage.

YGC : 新生代GC次数 Number of young generation GC events.

YGCT :新生代GC总耗费时间 Young generation garbage collection time.

FGC : 老年代GC次数 Number of full GC events.

FGCT: 老年代GC耗费时间 Full garbage collection time.

GCT :GC总耗时 Total garbage collection time.

jstat -printcompilation : Hotspot方法编译统计情况 Java HotSpot VM compiler method statistics.

[root@root ~]# jstat -printcompilation 1
Compiled  Size  Type Method
   31174   1055    1 sun/reflect/GeneratedMethodAccessor214 invoke

Compiled : 已编译方法次数 Number of compilation tasks performed by the most recently compiled method.

Size : 最近一次方法编译大小 Number of bytes of byte code of the most recently compiled method.

Type : 最近一次编译方法类型 Compilation type of the most recently compiled method.

Method : 最近一次编译方法 Class name and method name identifying the most recently compiled method. Class name uses slash (/) instead of dot (.) as a name space separator. Method name is the method within the specified class. The format for these two fields is consistent with the HotSpot -XX:+PrintCompilation option.

其他示例

使用-h3来每三行数据之后输出一次标题,每次数据数据时间间隔1秒:

[root@root ~]# jstat -gcnew -h3 1 1s
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51283.7   1133   11.980
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51283.8   1133   11.980
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51674.1   1133   11.980
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51816.1   1133   11.980
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51824.8   1133   11.980
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  51828.9   1133   11.980
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  52158.8   1133   11.980
17472.0 17472.0    0.0 1359.4 15  15 8736.0 139776.0  52312.8   1133   11.980

附

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

参考链接

1
  1. 1https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html#BEHHGFAEdocs.oracle.com
除非注明,否则均为李锋镝的博客原创文章,转载必须以链接形式标明本文链接

本文链接:https://www.lifengdi.com/article/tech/2056

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可
分享到

jstat命令使用(JDK1.8)

也可使用浏览器菜单中的「分享」功能

微信扫一扫分享

标签: JAVA JVM
最后更新:2021年5月8日
相关文章
  • 是时候优雅的和NullPointException说再见了2022年7月15日
  • Java中PO、VO、BO、DTO、POJO、DAO释义2019年6月28日
  • URL地址末尾加不加“/”有什么区别2025年5月23日
  • joda DateTime自定义格式&计算两个日期相差天数2019年8月2日
  • Java设计模式:模板方法模式2025年5月21日

李锋镝

既然选择了远方,便只顾风雨兼程。

打赏 点赞
< 上一篇
下一篇 >
1234567891112131415161718192021222324252627282930313233343536373839404142434446474849505152535455575859606162636465666769727476777879808182858687909293949596979899
取消回复

文章评论

还没有评论,快来抢沙发吧~

惟坚韧者始能遂其志。

听点儿音乐吧 朋友~
文章目录
最新 热点 随机
最新 热点 随机
支撑全网40%网站的WordPress正在重新拥抱PHP生态 Kratos-plus v1.1.24版本更新说明 关于主题加载速度优化的一点儿小演进 市场主流AI编程大模型横向深度分析(2026-09-11) 一款节省token的利器:RTK(Rust Token Killer) RAG太难学?LLM Wiki了解一下
给主题增加了Now、每日心情、年度回顾、岁月同一天、随机漫步等功能WordPress缓存插件WP Fastest Cache、WP Rocket 、FlyingPress对比关于使用AI的一些思考Kratos+ v1.1.16版本更新说明AI时代,个人技术博客的出路在哪里?推荐一个SVG 矢量小图标免费下载网站
Springboot接入DeepSeek API 详解 ZooKeeper 数据持久化 重构 Controller 终极指南:从臃肿到优雅的 7 大黄金法则 + 实战技巧 UUID太长怎么办?快来试试NanoId 写了个日期进度条的小插件 JMX监控权限认证配置
最近评论
blank
lijie blog 发布于 9 小时前(09月14日) 友链申请 名称:lijie blog 链接:https://lijie.cool 描述:懒于当...
blank
Hary 发布于 11 小时前(09月14日) 等PHP9推倒重来,出个船新版本
blank
李锋镝 发布于 23 小时前(09月14日) 不愧是皮总,这措辞~ :30:
blank
皮皮社长 发布于 23 小时前(09月14日) :20: 我勒了个去,中国汉字波大精深。 :42:
blank
李锋镝 发布于 23 小时前(09月14日) 我这里面也带了一堆小表情包,看看不行也优化一波
标签聚合
Redis WordPress AI SpringBoot Claude 架构 JAVA 分布式 AI编程 K8s ElasticSearch Spring 多线程 日常 IDEA MySQL MQ JVM SQL 数据库
友情链接
  • 若梦博客
  • 九仞之行
  • sssr7844的博客
  • Honesty
  • 彬红茶日记
  • 蜗牛工作室
  • 老张博客
  • 搬砖日记
  • 瓦匠个人小站
  • 志文工作室
  • 韩情脉脉
  • 知向前端
  • Serendipity
  • 临窗旋墨
  • 韩小韩博客
  • 皮皮社
  • 哥斯拉
  • Mr.Sun的博客
  • 懋和道人
  • 林羽凡

COPYRIGHT © 2016-2026 lifengdi.com. ALL RIGHTS RESERVED.

Domain age badge for lifengdi.com

Theme Kratos-plus By Dylan Li

津ICP备2024022503号-3

京公网安备11011502039375号