李锋镝的博客

  • 首页
  • 时间轴
  • 说说
  • 系列文章
  • AI工具集
  • 论坛
  • 左邻右舍
    • 左邻右舍
    • 朋友圈
    • 游客中心
  • 留言
    • 留言
    • 走心评论
  • 关于
    • 关于本站
    • Now
    • 每日心情
    • 网站地图
    • 网站统计
    • 赞助
  • 星球穿梭
  • 🚇开往
白雪成红
惟坚韧者始能遂其志
  1. 首页
  2. 原创
  3. 正文

jstat命令使用(JDK1.8)

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

概述

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 月 11 日

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

  • 中间件
    1 年前 2025年10月11日
    Kafka 为什么要抛弃 Zookeeper?

    Kafka 抛弃 Zookeeper(引入 KRaft 模式)是为了解决长期依赖 Zookeeper 带来的性能瓶颈、架…

  • 中间件
    1 年前 2025年10月11日
    高性能场景为什么推荐使用PostgreSQL,而非MySQL?

    在高性能场景(如高并发读写、复杂查询、大数据量存储、多维度数据处理等)中,PostgreSQL 常被优先推荐,核心原因在…

  • 原创
    7 年前 2019年10月11日
    JAVA关键字之volatile关键字说明

    volatile作用 volatile主要是为了解决多线程内存不可见问题。 对于一写多读,是可以解决变量同步问题,但是如…

相关文章
  • 解决Cannot connect to core dump or remote debug server. Use jhsdb jmap instead2025年4月9日
  • SpringBoot使用注解的方式构建Elasticsearch查询语句,实现多条件的复杂查询2019年9月12日
  • 【收藏】Java问题排查相关工具工具箱2019年10月16日
  • 了解一下Spring中用了哪些设计模式2019年10月20日
  • SpringBoot 实现 RSA+AES 自动接口解密2025年5月26日

李锋镝

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

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

文章评论

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

“先生先生,先别走耽误您两分钟时间我是XX理财公司的推销员,投我们公司,利率高达15%,稳赚不赔啊!”
“既然利润这么高你怎么不去投呢!”
“你不知道我们推销员都穷么!没钱!”
“没钱是吧,好好好,来来咱们坐下慢慢谈,我是搞小额贷款的,利息只有8%,你还有7%可以赚!哎哎哎,你别走啊!”

听点儿音乐吧 朋友~
文章目录
最新 热点 随机
最新 热点 随机
讨论下XXL-JOB GLUE模式的安全问题 心气没了,干什么都不得劲 Kratos-plus v1.1.26版本更新说明 我觉得是时候公布我的导航网站了 代码是 AI 写的,生产事故谁背锅? 给主题增加了游客中心功能
给主题增加了游客中心功能我觉得是时候公布我的导航网站了游本昌去世关于主题加载速度优化的一点儿小演进给主题增加了Now、每日心情、年度回顾、岁月同一天、随机漫步等功能心气没了,干什么都不得劲
MySQL数据库详解——执行SQL查询语句时,其底层到底经历了什么? 精通Linux根目录:核心文件夹深度解析与实战指南 Dockerfile指令详解之COPY和ADD 【三国轶闻】张飞多次挑衅吕布却安然无事,吕布到底害怕张飞什么? 几款Java开发者必备常用的工具,准点下班不在话下 基于Java8的Either类
最近评论
老张博客 发布于 11 小时前(10月10日) NAS现在就不要搞了吧,除非你手里有内存和硬盘。
李锋镝 发布于 16 小时前(10月10日) 确实,很多不必要的东西,买了回来也是吃灰……
林羽凡 发布于 20 小时前(10月10日) 一个是不想折腾了,另一个有些觉得没必要的折腾或购买,想想就会算了。
李锋镝 发布于 20 小时前(10月10日) 少年老成吧大概是 :21:
Hary 发布于 20 小时前(10月10日) 我也是这样,感觉都不想折腾了,我还没到中年呢吧啊啊啊
标签聚合
JAVA 架构 IDEA MySQL Theme Spring AI编程 ElasticSearch 多线程 数据库 分布式 JVM 日常 SQL SpringBoot Redis AI K8s WordPress Claude
友情链接
  • 知向前端
  • 韩情脉脉
  • 搬砖日记
  • 老张博客
  • 彬红茶日记
  • 韩小韩博客
  • lijie blog
  • Honesty
  • 林羽凡
  • 懋和道人
  • sssr7844的博客
  • 九仞之行
  • Serendipity
  • 哥斯拉
  • 志文工作室
  • 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号