一 点睛
dashboard 当前系统的实时数据面板
thread 查看当前 JVM 的线程堆栈信息
二 代码
package chapter03;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
public class JProfilerTest {
public static void main(String[] args) {
while (true){
ArrayList list = new ArrayList();
for (int i = 0; i < 500; i++) {
Data data = new Data();
list.add(data);
}
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Data{
private int size = 10;
private byte[] buffer = new byte[1024*1024]; // 1 mb
private String info = "hello,China";
}
三 windows下进入命令界面
D:\ProgramFiles\arthas-packaging-3.5.4-bin>jps
10656 Jps
12736 Launcher
2864
10668 JProfilerTest
D:\ProgramFiles\arthas-packaging-3.5.4-bin>as.bat 10668
环境变量 JAVA_TOOL_OPTIONS 没有定义
JAVA_HOME: D:\ProgramFiles\Java\jdk1.8.0_251
telnet port: 3658
http port: 8563
信息: 用提供的模式无法找到文件。
telnet wasn't found, please google how to install telnet under windows.
Try to visit http://127.0.0.1:8563 to connecto arthas server.
四 实战
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki https://arthas.aliyun.com/doc
tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html
version 3.5.4
main_class
pid 10668
time 2021-09-04 09:12:08
# dashboard 实时打印数据,不停打印
[arthas@10668]$ dashboard
# 第一次打印
ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTED DAEMON
1 main main 5 TIMED_WAITI 0.0 0.000 1:21.281 false false
-1 GC task thread#1 (ParallelGC) - -1 - 0.0 0.000 1:13.562 false true
-1 GC task thread#5 (ParallelGC) - -1 - 0.0 0.000 1:13.406 false true
-1 GC task thread#4 (ParallelGC) - -1 - 0.0 0.000 1:13.250 false true
-1 GC task thread#3 (ParallelGC) - -1 - 0.0 0.000 1:12.953 false true
-1 GC task thread#7 (ParallelGC) - -1 - 0.0 0.000 1:12.843 false true
-1 GC task thread#2 (ParallelGC) - -1 - 0.0 0.000 1:12.734 false true
-1 GC task thread#0 (ParallelGC) - -1 - 0.0 0.000 1:12.625 false true
-1 GC task thread#6 (ParallelGC) - -1 - 0.0 0.000 1:12.250 false true
-1 VM Thread - -1 - 0.0 0.000 0:4.468 false true
-1 C1 CompilerThread3 - -1 - 0.0 0.000 0:1.093 false true
-1 C2 CompilerThread2 - -1 - 0.0 0.000 0:0.796 false true
-1 C2 CompilerThread1 - -1 - 0.0 0.000 0:0.562 false true
Memory used total max usage GC
heap 1537M 3399M 3399M 45.22% gc.ps_scavenge.count 2751
ps_eden_space 50M 425M 425M 11.84% gc.ps_scavenge.time(ms) 86386
ps_survivor_space 424M 424M 424M 99.94% gc.ps_marksweep.count 129
ps_old_gen 1062M 2549M 2549M 41.68% gc.ps_marksweep.time(ms) 6840
nonheap 32M 35M -1 91.62%
code_cache 6M 8M 240M 2.72%
metaspace 23M 24M -1 95.20%
compressed_class_space 2M 2M 1024M 0.27%
direct 0K 0K - 0.00%
mapped 0K 0K - 0.00%
Runtime
os.name Windows 10
os.version 10.0
java.version 1.8.0_251
java.home D:\ProgramFiles\Java\jdk1.8.0_251\jre
systemload.average -1.00
processors 8
timestamp/uptime Sat Sep 04 09:14:47 CST 2021/1430s
# 第二次打印
ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTED DAEMON
-1 GC task thread#0 (ParallelGC) - -1 - 6.54 0.328 1:12.953 false true
-1 GC task thread#3 (ParallelGC) - -1 - 6.23 0.312 1:13.265 false true
1 main main 5 TIMED_WAITI 5.92 0.296 1:21.578 false false
-1 GC task thread#1 (ParallelGC) - -1 - 5.92 0.296 1:13.859 false true
-1 GC task thread#4 (ParallelGC) - -1 - 5.92 0.296 1:13.546 false true
-1 GC task thread#7 (ParallelGC) - -1 - 5.61 0.281 1:13.125 false true
-1 GC task thread#2 (ParallelGC) - -1 - 5.61 0.281 1:13.015 false true
-1 GC task thread#5 (ParallelGC) - -1 - 5.61 0.281 1:13.687 false true
-1 GC task thread#6 (ParallelGC) - -1 - 4.98 0.250 1:12.500 false true
111 Timer-for-arthas-dashboard-bf73c6be- system 5 RUNNABLE 0.93 0.046 0:0.046 false true
106 arthas-NettyWebsocketTtyBootstrap-4- system 5 RUNNABLE 0.62 0.031 0:0.328 false true
-1 C2 CompilerThread0 - -1 - 0.31 0.015 0:0.468 false true
-1 C1 CompilerThread3 - -1 - 0.31 0.015 0:1.109 false true
Memory used total max usage GC
heap 2523M 3399M 3399M 74.23% gc.ps_scavenge.count 2761
ps_eden_space 309M 425M 425M 72.68% gc.ps_scavenge.time(ms) 86751
ps_survivor_space 194M 424M 424M 45.76% gc.ps_marksweep.count 129
ps_old_gen 2020M 2549M 2549M 79.23% gc.ps_marksweep.time(ms) 6840
nonheap 32M 35M -1 92.78%
code_cache 6M 8M 240M 2.79%
metaspace 23M 24M -1 96.10%
compressed_class_space 2M 2M 1024M 0.27%
direct 0K 0K - 0.00%
mapped 0K 0K - 0.00%
Runtime
os.name Windows 10
os.version 10.0
java.version 1.8.0_251
java.home D:\ProgramFiles\Java\jdk1.8.0_251\jre
systemload.average -1.00
processors 8
timestamp/uptime Sat Sep 04 09:14:52 CST 2021/1435s
# 第三次打印
ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTED DAEMON
-1 GC task thread#6 (ParallelGC) - -1 - 6.87 0.343 1:12.843 false true
-1 GC task thread#3 (ParallelGC) - -1 - 6.87 0.343 1:13.609 false true
-1 GC task thread#5 (ParallelGC) - -1 - 6.87 0.343 1:14.031 false true
-1 GC task thread#2 (ParallelGC) - -1 - 6.56 0.328 1:13.343 false true
-1 GC task thread#7 (ParallelGC) - -1 - 6.25 0.312 1:13.437 false true
-1 GC task thread#4 (ParallelGC) - -1 - 6.25 0.312 1:13.859 false true
-1 GC task thread#0 (ParallelGC) - -1 - 5.93 0.296 1:13.250 false true
-1 GC task thread#1 (ParallelGC) - -1 - 5.93 0.296 1:14.156 false true
1 main main 5 RUNNABLE 5.62 0.281 1:21.859 false false
-1 VM Thread - -1 - 0.93 0.046 0:4.531 false true
106 arthas-NettyWebsocketTtyBootstrap-4- system 5 RUNNABLE 0.31 0.015 0:0.343 false true
-1 C2 CompilerThre