李锋镝的博客

  • 首页
  • 时间轴
  • 说说
  • 读书观影
  • 系列
  • AI工具集
  • 论坛
  • 友圈
    • 友链
    • 朋友圈
    • 游客中心
  • 留言
    • 留言
    • 走心评论
  • 关于
    • 关于本站
    • Now
    • 每日心情
    • 网站地图
    • 网站统计
    • 赞助
  • 星球穿梭
  • 🚇开往
静亦定 动亦定
惟坚韧者始能遂其志
  1. 首页
  2. 原创
  3. 正文

jstat命令使用(JDK1.8)

2020年8月12日 311 0 0
本文最后更新于 2021年5月8日,距今已 1994 天,其中的信息可能已经发生变化,请注意甄别。

概述

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

jstat命令使用(JDK1.8)

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

微信扫一扫分享

标签: JAVA JVM
最后更新:2021年5月8日

岁月同一天 10 月 24 日

回望过去的今天,你在写什么

  • 中间件
    1 年前 2025年10月24日
    为什么不建议在 Docker 中运行 MySQL?从技术原理到实践避坑

    在开发圈,Docker 早已成为“快速部署”的代名词——一行命令启动 Redis、Nginx,甚至整个微服务集群,这种便…

  • 7 年前 2019年10月24日
    用动画解释 TCP 三次握手过程

    写在前边 TCP 三次握手过程对于面试是必考的一个,所以不但要掌握 TCP 整个握手的过程,其中有些小细节也更受到面试官…

  • 7 年前 2019年10月24日
    Elasticsearch中的多索引、多类型搜索

    如果不对某一特殊的索引或者类型做限制,就会搜索集群中的所有文档。Elasticsearch转发搜索请求到每一个主分片或者…

相关文章
  • jmap命令(jdk1.8)2020年9月27日
  • ThreadPoolExecutor如何实现线程复用及超时销毁2021年6月18日
  • 查看占用 CPU 最高的线程(Java)2021年5月27日
  • Java设计模式-单例模式2020年1月6日
  • SpringBoot整合Elasticsearch详细步骤以及代码示例(附源码)2019年9月20日

李锋镝

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

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

文章评论

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

有位老头低着头在他家的麦田小路上转悠,这时走过来一个盛气凌人的年轻人,他趾高气扬的对老头说:“你总这样低着头走路,多难看啊!”
老头道:“要是田里的麦子都像你一样,人们早就饿死了。”

听点儿音乐吧 朋友~
文章目录
最新 热点 随机
最新 热点 随机
NGINX严重漏洞(CVE-2026-15176、CVE-2026-93479、CVE-2026-97205) Kratos-plus v1.1.27更新说明 php2shell远程执行漏洞修复(CVE-2026-109618 和 CVE-2026-109619) 聊一聊DeepSeek开放自研搜索API这事 Let's Encrypt宣布证书缩短至64天,手动时代彻底终结! Markdown 的前世今生
给主题增加了游客中心功能心气没了,干什么都不得劲我觉得是时候公布我的导航网站了游本昌去世关于主题加载速度优化的一点儿小演进给主题增加了Now、每日心情、年度回顾、岁月同一天、随机漫步等功能
张爱玲——《红玫瑰与白玫瑰》 Spring Boot 2.x使用PostgreSQL数据库 零成本玩转 Gemini 3 Pro:普通人的全场景免费使用指南(2025 最新) 网易云什么时候能有杰伦的歌…… php2shell远程执行漏洞修复(CVE-2026-109618 和 CVE-2026-109619) 不慌不忙的坚强(林徽因39段最美文字!)
最近评论
李锋镝 发布于 18 小时前(10月23日) 哈哈哈,确实,经常有些网站证书过期的
李锋镝 发布于 18 小时前(10月23日) 这样更省事
fairy 发布于 1 天前(10月23日) 我挺支持这个的,自己的站,还是要看看的。证书过期都不知道,还不如关站算了。
fairy 发布于 1 天前(10月23日) 我小站,直接apt update && apt upgrade 就解决了,现在是8....
李锋镝 发布于 2 天前(10月22日) 赞!置顶了,让更多人看到~
标签聚合
分布式 架构 Redis JVM MySQL SpringBoot JAVA IDEA AI Spring Theme 日常 WordPress SQL AI编程 K8s ElasticSearch Claude 多线程 数据库
友情链接
  • 搬砖日记
  • 林羽凡
  • sssr7844的博客
  • 志文工作室
  • Honesty
  • Serendipity
  • 韩情脉脉
  • 哥斯拉
  • 懋和道人
  • 韩小韩博客
  • 瓦匠个人小站
  • 彬红茶日记
  • 刘永博客
  • 知向前端
  • 老张博客
  • lijie blog
  • 皮皮社
  • Mr.Sun的博客
  • 九仞之行

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

lifengdi.com 十年之约虫洞

Domain age badge for lifengdi.com

Theme Kratos-plus By Dylan Li

津ICP备2024022503号-3

京公网安备11011502039375号