jstack命令排查性能问题

使用top -Hp命令查看某进程里面,资源占用率高的线程id。通过Java自带的jstack命令查看线程id中锁死的代码行。

排查步骤

  1. 找到出现问题的进程
top 命令,大写M(按照进程占用内存排序),大写P(按照进程占用CPU排序)
或ps -ef|grep keyword
  1. top -Hp pid 查看占用最多资源的线程

图片

  1. 把线程pid转换成16进制数

    这里我们看到的占用最多资源的线程是:3440

    使用命令printf “%x\n” 3440 把线程pid转换成16进制数,得到:d70。

  2. 利用jstack命令查看此进程的快照信息

    使用jstack 3429 | grep -20 d70命令查询该线程阻塞的地方

图片

jstack命令

作用:生成JVM当前时刻线程的快照(threaddump,即当前进程中所有线程的信息)

目的:帮助定位程序问题出现的原因,如长时间停顿、CPU占用率过高等

top命令

-**H **:Threads-mode operation

        Instructs top to display individual threads.  Without this

        command-line option a summation of all threads in each process

        is shown.  Later this can be changed with the `H' interactive

        command.

-**p **:Monitor-PIDs mode as: **-pN1 -pN2 … **or -pN1,N2,N3 .

jstat查看gc信息

jstat -gcutil 21891 250 7
This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the -gcutil option.

参考文档

https://blog.csdn.net/moakun/article/details/80086777

http://man7.org/linux/man-pages/man1/top.1.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值