【视频笔记】如何使用 Arthas,排查线上代码问题。jvm内存占用、方法出入参、线上代码类、大对象等。非常好用!
arthas适用哪些场景

# 案例程序
curl -O https://arthas.aliyun.com/math-game.jar
jar -jar math-game.jar
常用命令(官网)
https://arthas.aliyun.com/doc/commands.html
arthas实时数据面板

生成火焰图
profiler start --event alloc
profiler getSamples
profiler getSamples
profiler stop --format html
本地虚拟机操作如下

用浏览器打开火线图

arthas有关idea插件
Arthas Idea

代码中拷贝arthas命令

点击Monitor之后拷贝出如下命令
monitor cn.bugstack.xfg.dev.tech.Application exec -n 10 --cycle 10
查看线上运行代码
从Decompile Class Jad拷贝命令

jad --source-only cn.bugstack.xfg.dev.tech.Application exec

鼠标右键查看watch命令
watch cn.bugstack.xfg.dev.tech.Application exec '{params,returnObj,throwExp}' -n 5 -x 3

arthas是怎么实现这些功能的呢
字节码增强的三个框架
ASM
Javassist
Byte-Buddy

参考:
博客地址: https://bugstack.cn/md/road-map/arthas.html
示例代码:https://github.com/fuzhengwei/xfg-dev-tech-arthas
b站视频: https://www.bilibili.com/video/BV1vTyaYeEHq?spm_id_from=333.788.player.switch&vd_source=291e6cab5cbcdc273e854ed8b1478e75
浙公网安备 33010602011771号