原创

调优-arthas-Java应用诊断利器

相关文档:

https://arthas.aliyun.com/doc
http://arthas.gitee.io/
Arthas问题排除案例
https://www.cnblogs.com/yifanSJ/p/17723333.html

下载:
curl -O https://arthas.aliyun.com/arthas-boot.jar

下载全量包
https://github.com/alibaba/arthas/releases

运行:
java -jar arthas-boot.jar --repo-mirror aliyun --use-http
(需要权限时 sudo su admin && java -jar arthas-boot.jar 或 sudo -u admin -EH java -jar arthas-boot.jar)
java -jar arthas-boot.jar --repo-mirror aliyun --use-http
输入数字序号回车选择

关闭已有的arthas进程
java -jar arthas-bin/arthas-client.jar 127.0.0.1 3658 -c "stop"

查看线程相关:
thread -n 3 指定最忙的前N个线程并打印堆栈
thread -b 找出阻塞其它线程的线程
thread --state RUNNABLE
thread --state WAITING
thread -i 1000 : 统计最近 1000ms 内的线程 CPU 时间。
thread -n 3 -i 1000 : 列出 1000ms 内最忙的 3 个线程栈
更多命令说明:
https://arthas.aliyun.com/doc/thread.html
https://arthas.aliyun.com/doc/commands.html


可能的原理:
Packages that use com.sun.tools.attach
Package Description
com.sun.tools.attach
Provides the API to attach to a JavaTM virtual machine.
com.sun.tools.attach.spi
Only developers who are defining new attach providers should need to make direct use of this package.
List<String> ids = getAllVMIdList();
HotSpotVirtualMachine vm = (HotSpotVirtualMachine) HotSpotVirtualMachine.attach(id);
try (InputStream in = vm.dumpHeap("./heapdump.hprof"))
         ......

正文到此结束
本文目录