诊断神器Xrebel和Arthas

929 阅读1分钟

诊断工具Xrebel和Arthas

Xrebel

//添加jvm参数
-javaagent:"C:\Program Files\Java\xrebel.jar"

可以看到每一项的耗时,第一次访问接口速度明显十分慢,懒加载的问题。这里可以看到大部分的时间都用在SHA256加密验证上了。

image.png

数据库连接断开也会报告 image.png

功能还是比较全面的 image.png

Arthas

java -jar直接启动,然后选择需要监听的线程

C:\Users\kyz\Downloads>java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.4.5
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 11044 org.jetbrains.jps.cmdline.Launcher
  [2]: 12616
  [3]: 15836 ltd.wiki.water.WaterApplication
3
[INFO] Start download arthas from remote server: https://arthas.aliyun.com/download/3.5.0?mirror=aliyun
[INFO] File size: 12.22 MB, downloaded size: 9.68 MB, downloading ...
[INFO] Download arthas success.
[INFO] arthas home: C:\Users\kyz\.arthas\lib\3.5.0\arthas
[INFO] Try to attach process 15836
[INFO] Attach process 15836 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.5.0
main_class
pid        15836
time       2021-04-02 21:02:33

//查看帮助
help

image.png

//查看线程占用,Xrebel都给找出来了
thread 

image.png

//查看死锁
thread -b

[arthas@2997]$ thread -b
"Thread-3" Id=29 BLOCKED on java.lang.Object@3f20bf9 owned by "Thread-4" Id=30
    at com.spareyaya.jvm.service.DeadLockService.service1(DeadLockService.java:27)
    -  blocked on java.lang.Object@3f20bf9
    -  locked java.lang.Object@2fea801a <---- but blocks 1 other threads!
    at com.spareyaya.jvm.controller.JVMController.lambda$deadLock$0(JVMController.java:37)
    at com.spareyaya.jvm.controller.JVMController$$Lambda$456/748979989.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)
//查看内存是否泄露
dashboard

image.png