Arthas的火焰图生成

本文演示了如何使用Arthas工具在本地JVM进程中生成火焰图。首先下载Arthas并连接到目标进程,然后通过`profilerstart`、`profilerstatus`和`profilerstop--formathtml`等命令进行性能采样和生成HTML格式的火焰图,最后打开生成的文件查看分析结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前说过用idea自带的工具生成火焰图,但是idea是在本地的,在机器上如何生成呢?
我觉得方法有很多,这里用arthas工具简单搞一搞
Arthas官网地址

下载Arthas

如果在机器上要下载整个包,arthas-boot.jar需要依赖其他的jar包

操作

进入到jvm进程中

 ~/software/arthas/ java -jar arthas-boot.jar
[INFO] JAVA_HOME: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
[INFO] arthas-boot version: 3.6.9
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 2033 
  [2]: 2070 org.jetbrains.idea.maven.server.RemoteMavenServer36
  [3]: 2118 math-game.jar
  [4]: 2072 org.jetbrains.jps.cmdline.Launcher
3
[INFO] Try to attach process 2118
Picked up JAVA_TOOL_OPTIONS: 
[INFO] Attach process 2118 success.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.                           
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'                          
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.                          
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |                         
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'                          

wiki       https://arthas.aliyun.com/doc                                        
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html                  
version    3.6.9                                                                
main_class demo.MathGame                                                        
pid        2118                                                                 
time       2023-07-15 12:55:44                                                  

[arthas@2118]$ 

开始采集

[arthas@2118]$ profiler start
Profiling started
[arthas@2118]$ 
[arthas@2118]$ 
[arthas@2118]$ profiler getSamples
22
[arthas@2118]$ 
[arthas@2118]$ profiler status
Profiling is running for 52 seconds
[arthas@2118]$ 
[arthas@2118]$ profiler stop --format html
OK
profiler output file: /Users/lixi/software/arthas/arthas-output/20230715-125705.html
[arthas@2118]$ 
[arthas@2118]$ 

查看

open /Users/lixi/software/arthas/arthas-output/20230715-125705.html

在这里插入图片描述

选择 main 方法

在这里插入图片描述

总结

方法很简单,主要用到的命令

profiler start
profiler status
profiler stop --format html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值