zl程序教程

您现在的位置是:首页 >  后端

当前栏目

java 15: jstat查看类或编译器信息

JAVA编译器 查看 信息 15 jstat
2023-09-14 09:01:18 时间

一,jstat:查看帮助或选项

1,查看帮助
[lhdop@blog ~]$ jstat --help
Usage: jstat --help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
... 
2,查看可用的选项
[lhdop@blog ~]$ jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,jstat访问类、编译器的常用方法

1,先找一个用来访问的java进程:

[lhdop@blog ~]$ jps
24723 Jps
20756 storeback-0.0.1-SNAPSHOT.jar 
 
2,class:统计class loader的信息
[lhdop@blog ~]$ jstat -class 20756
Loaded  Bytes  Unloaded  Bytes     Time
11488 21425.1        0     0.0       4.60
Loaded:  有多少个class被加载
Bytes:  被加载的class大小
Unloaded:  有多少个class被反加载
Bytes:  被反加载的class大小
Time:  加载和反加载class花费的时间
 
3,统计JIT即时编译器的信息
[lhdop@blog ~]$ jstat -compiler 20756
Compiled Failed Invalid   Time   FailedType FailedMethod
    8933      0       0    14.16          0             
Compiled:  执行的编译任务的次数
Failed:  编译任务失败次数
Invalid:   置位无效的编译任务次数
Time:   执行编译任务花费的时间
FailedType:   上一次编译失败的编译类型
FailedMethod:   上一次编译失败的方法名
 
4,printcompilation:JVM编译器的方法统计
[lhdop@blog ~]$ jstat -printcompilation 20756
Compiled  Size  Type Method
    8934   1146    1 org/apache/tomcat/util/net/NioEndpoint$Poller run
Compiled:  最近执行的编译任务次数
Size:  最近编译方法的大小
Type:  最新编译方法的类型
Method:  最新编译方法的名字

三,查看java版本:

[lhdop@blog tools]$ java --version
java 15 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)