当前位置:网站首页>JVM调试工具-jstack
JVM调试工具-jstack
2022-06-24 06:39:00 【Angryshark_128】
jstack
常用命令
打印栈信息
> jstack 23766
2020-09-17 09:07:23
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.191-b12 mixed mode):
...
"GC task thread#22 (ParallelGC)" os_prio=0 tid=0x00007fd21c049000 nid=0x5cef runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007fd21c451800 nid=0x5d09 waiting on condition
JNI global references: 9644
打印附加锁信息,耗时较长,不建议使用
> jstack -l 23766
2020-09-17 09:10:47
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.191-b12 mixed mode):
"Ftp-JS-20200917-outputDetail" #26254 prio=5 os_prio=0 tid=0x00007fd04c086800 nid=0x31e8 waiting on condition
...
"GC task thread#22 (ParallelGC)" os_prio=0 tid=0x00007fd21c049000 nid=0x5cef runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007fd21c451800 nid=0x5d09 waiting on condition
JNI global references: 9648
打印java和native c/c++框架的所有栈信息.可以打印JVM的堆栈,显示上Native的栈帧,一般应用排查不需要使用
> jstack -m 23766
Attaching to process ID 23766, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.191-b12
Deadlock Detection:
No deadlocks found.
----------------- 23768 -----------------
0x00007fd22506c6d5 __pthread_cond_wait + 0xc5
0x00007fd224167d09 _ZN7Monitor5IWaitEP6Threadl + 0xe9
0x00007fd224169130 _ZN7Monitor4waitEblb + 0xf0
0x00007fd2243174d1 _ZN7Threads10destroy_vmEv + 0x51
0x00007fd223f5f366 jni_DestroyJavaVM + 0x76
0x00007fd224e513a8 JavaMain + 0x5b8
----------------- 23769 -----------------
0x00007fd22418ea53 _ZN13ObjArrayKlass19oop_follow_contentsEP20ParCompactionManagerP7oopDesc + 0x573
0x00007fd224210b6f _ZN20ParCompactionManager21follow_marking_stacksEv + 0xdf
0x00007fd2241f3a7b _ZN16StealMarkingTask5do_itEP13GCTaskManagerj + 0x2bb
0x00007fd223e60f36 _ZN12GCTaskThread3runEv + 0x1b6
0x00007fd2241a9c92 _ZL10java_startP6Thread + 0x102
...
jstat
jstat的主要作用就是对Java应用程序的资源和性能进行实时监控的命令行工具,主要包括GC情况和Heap Size资源使用情况。
命令个数:jstat - [-t] [-h] [ []]
option 常见的都是使用-gcutil查看gc情况,其他可选项见下图。
vmid : VM的进程号,即当前运行的java进程号。
interval : 间隔时间,单位为秒或毫秒
count:打印次数,如果缺省则打印无数次。
-class 统计加载class的数量及其所占空间大小等信息
-compiler 统计HotSpot实时编译的数量等信息
-gc 统计gc信息,包括young gc次数、young gc时间、full gc次数、full gc时间和gc总时间
-gccapacity 统计gc时,不同generations内存大小
-gccause 统计gc时,最近一次GC的信息(等效于-gcutil)和引起gc原因
-gcpermcapacity 统计gc时,permanent区大小(JDK7及其以前版本)
-gcmetacapacity 统计gc时,metaspace区大小(JDK8及其以后版本)
-gcnew 统计gc时,新生代内对象的信息
-gcnewcapacity 统计gc时,新生代大小
-gcold 统计gc时,老年代内对象的信息
-gcoldcapacity 统计gc时,老年代大小
-gcutil 统计gc时,最近一次GC的信息
-printcompilation hotspot编译方法统计
常用命令
垃圾回收统计,查看gc的统计信息,已使用/总空间的占比情况。
> jstat -gcutil 23766
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
0.00 0.00 100.00 100.00 95.49 93.77 22256 2012.576 1843 5430.080 7442.657
| 参数 | 描述 |
|---|---|
| S0 | 年轻代中第一个survivor(幸存区)已使用的占当前容量百分比 |
| s1 | 年轻代中第二个survivor(幸存区)已使用的占当前容量百分比 |
| E | 年轻代中Eden已使用的占当前容量百分比 |
| O | old代已使用的占当前容量百分比 |
| M | 元空间(MetaspaceSize)已使用的占当前容量百分比 |
| CCS | 压缩使用比例 |
| YGC | 年轻代垃圾回收次数 |
| FGC | 老年代垃圾回收次数 |
| FGCT | 老年代垃圾回收消耗时间 |
| GCT | 垃圾回收消耗总时间 |
堆内存使用情况统计,单位KB
> jstat -gccapacity 23766
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC
698880.0 10484736.0 10484736.0 3494912.0 3494912.0 3494912.0 1398272.0 20970496.0 20970496.0 20970496.0 0.0 1099776.0 57128.0 0.0 1048576.0 6952.0 22256 1881
| 参数 | 描述 |
|---|---|
| NGCMN | 新生代最小容量 |
| NGCMX | 新生代最大容量 |
| NGC | 当前新生代容量 |
| S0C | 第一个幸存区大小 |
| S1C | 第二个幸存区的大小 |
| EC | 伊甸园区的大小 |
| OGCMN | 老年代最小容量 |
| OGCMX | 老年代最大容量 |
| OGC | 当前老年代大小 |
| OC | 当前老年代大小 |
| MCMN | 最小元数据容量 |
| MCMX | 最大元数据容量 |
| MC | 当前元数据空间大小 |
| CCSMN | 最小压缩类空间大小 |
| CCSMX | 最大压缩类空间大小 |
| CCSC | 当前压缩类空间大小 |
| YGC | 年轻代gc次数 |
| FGC | 老年代GC次数 |
类加载统计
> jstat -class 23766
Loaded Bytes Unloaded Bytes Time
9193 17909.9 51 70.4 3821.14
| 参数 | 描述 |
|---|---|
| Loaded | 加载class的数量 |
| Bytes | 所占用空间大小 |
| Unloaded | 未加载数量 |
| Bytes | 未加载占用空间 |
| Time | 时间 |
查看编译任务状态
> jstat -compiler 23766
Compiled Failed Invalid Time FailedType FailedMethod
8491 3 0 1305.48 1 com/alibaba/druid/pool/DruidDataSource shrink
| 参数 | 描述 |
|---|---|
| Compiled | 编译任务执行数量 |
| Failed | 编译任务执行失败数量 |
| Invalid | 编译任务执行失效数量 |
| Time | 编译任务消耗时间 |
| FailedType | 最后一个编译失败任务的类型 |
| FailedMethod | 最后一个编译失败任务所在的类及方法 |
查看编译任务
> jstat -printcompilation 23766
Compiled Size Type Method
8492 80 1 sun/text/resources/FormatData <init>
| 参数 | 描述 |
|---|---|
| Compiled | 编译任务的数目 |
| Size | 方法生成的字节码的大小 |
| Type | 编译类型 |
| Method | 类名和方法名用来标识编译的方法 |
边栏推荐
- CloudCompare&PCL 点云裁剪(基于裁剪盒)
- Thread safety and its implementation
- RealNetworks vs. Microsoft: the battle in the early streaming media industry
- System design: partition or data partition
- [binary number learning] - Introduction to trees
- 记录--关于JSP前台传参数到后台出现乱码的问题
- Five minute run through 3D map demo
- 机器人迷雾之算力与智能
- What is JSP technology? Advantages of JSP technology
- GPU frequency of zhanrui chip
猜你喜欢

Rockscache schematic diagram of cache operation

leetcode:85. 最大矩形

With a goal of 50million days' living, pwnk wants to build a "Disneyland" for the next generation of young people

Counter attack of flour dregs: MySQL 66 questions, 20000 words + 50 pictures

RealNetworks vs. Microsoft: the battle in the early streaming media industry

puzzle(019.1)Hook、Gear
![Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.](/img/2c/d04f5dfbacb62de9cf673359791aa9.png)
Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.
![跳跃游戏II[贪心练习]](/img/e4/f59bb1f5137495ea357462100e2b38.png)
跳跃游戏II[贪心练习]

网吧管理系统与数据库
![Jumping game ii[greedy practice]](/img/e4/f59bb1f5137495ea357462100e2b38.png)
Jumping game ii[greedy practice]
随机推荐
35岁危机?内卷成程序员代名词了
Counter attack of flour dregs: MySQL 66 questions, 20000 words + 50 pictures
Go excel export tool encapsulation
LuChen technology was invited to join NVIDIA startup acceleration program
What are the audio formats? Can the audio format be converted
Spark项目打包优化实践
Five minute run through 3D map demo
What are the easy-to-use character recognition software? Which are the mobile terminal and PC terminal respectively
How do I reinstall the system? How to install win10 system with USB flash disk?
puzzle(019.1)Hook、Gear
数据同步工具 DataX 已经正式支持读写 TDengine
如何低成本构建一个APP
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
你有一个机会,这里有一个舞台
35 year old crisis? It has become a synonym for programmers
Asp+access web server reports an error CONN.ASP error 80004005
Nine unique skills of Huawei cloud low latency Technology
Easy car Interviewer: talk about MySQL memory structure, index, cluster and underlying principle!
Internet cafe management system and database
Programmers use personalized Wallpapers