arthas
2025/9/8小于 1 分钟约 216 字
简介&安装
# 官网
https://arthas.aliyun.com/doc/expert/user-question-history11443.html
# 下载
curl -O https://arthas.aliyun.com/arthas-boot.jar
wget https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar
# trace 消耗时长
trace io.renren.modules.line.service.impl.ThirdSendServiceImpl signChat -n 5 --skipJDKMethod false
# watch 查看出入参数
watch io.renren.modules.line.service.impl.ThirdSendServiceImpl signChat '{params,returnObj,throwExp}' -n 5 -x 3
# stack 堆栈信息
stack io.renren.modules.line.service.impl.ThirdSendServiceImpl signChat -n 5
排查线程等待 找出countdown sync状态 和判断线程卡在什么地方
# 找到阻塞线程 查看堆栈信息 看countdownLatch的sync实例
thread --state WAITING | grep hhx
# 找到所有的countdownLatch的sync实例可用看状态
vmtool --action getInstances --className java.util.concurrent.CountDownLatch$Sync
线程相关
thread # 查看所有线程信息
thread -n 3 # 查看最忙的3个线程
thread -b # 找出当前阻塞其他线程的线程
thread 1 # 查看线程ID为1的线程的堆栈
heapdump /tmp/dump.hprof # 生成堆转储文件
memory # 查看内存情况