Arthas 的 dashboard 命令和 thread 命令实战

一 点睛

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 CompilerThread2                   -                 -1          -           0.31        0.015        0:0.812     false       true
-1    C2 CompilerThread0                   -                 -1          -           0.31        0.015        0:0.484     false       true
Memory                         used       total     max        usage     GC
heap                           1392M      3399M     3399M      40.97%    gc.ps_scavenge.count                 2772
ps_eden_space                  10M        425M      425M       2.51%     gc.ps_scavenge.time(ms)              87126
ps_survivor_space              424M       424M      424M       99.94%    gc.ps_marksweep.count                130
ps_old_gen                     957M       2549M     2549M      37.57%    gc.ps_marksweep.time(ms)             6904
nonheap                        33M        35M       -1         93.20%
code_cache                     6M         8M        240M       2.84%
metaspace                      23M        24M       -1         96.25%
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:57 CST 2021/1440s

# 500毫秒打印一次
[arthas@10668]$ dashboard -i 500
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#7 (ParallelGC)        -                 -1          -           10.75       0.109        1:30.203    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           10.75       0.109        1:31.234    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           7.68        0.078        1:30.109    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           7.68        0.078        1:29.890    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           7.68        0.078        1:30.421    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           7.68        0.078        1:31.046    false       true
1     main                                 main              5           TIMED_WAITI 6.14        0.062        1:35.734    false       false
-1    GC task thread#6 (ParallelGC)        -                 -1          -           4.61        0.046        1:29.375    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           4.61        0.046        1:31.265    false       true
112   Timer-for-arthas-dashboard-bf73c6be- system            5           RUNNABLE    1.53        0.015        0:0.015     false       true
-1    C1 CompilerThread3                   -                 -1          -           1.53        0.015        0:1.328     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.015     false       true
Memory                         used       total     max        usage     GC
heap                           2022M      3399M     3399M      59.51%    gc.ps_scavenge.count                 3386
ps_eden_space                  207M       425M      425M       48.81%    gc.ps_scavenge.time(ms)              106263
ps_survivor_space              297M       424M      424M       70.02%    gc.ps_marksweep.count                153
ps_old_gen                     1517M      2549M     2549M      59.54%    gc.ps_marksweep.time(ms)             8292
nonheap                        34M        35M       -1         96.87%
code_cache                     7M         8M        240M       3.25%
metaspace                      23M        24M       -1         97.46%
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:19:57 CST 2021/1740s
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
1     main                                 main              5           TIMED_WAITI 4.6         0.046        1:35.781    false       false
-1    C2 CompilerThread0                   -                 -1          -           4.6         0.046        0:0.593     false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           1.53        0.015        1:30.218    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           1.53        0.015        1:29.390    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           1.53        0.015        1:30.125    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           1.53        0.015        1:31.281    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           1.53        0.015        1:29.906    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           1.53        0.015        1:30.437    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           1.53        0.015        1:31.062    false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.015     false       true
4     Signal Dispatcher                    system            9           RUNNABLE    0.0         0.000        0:0.000     false       true
5     Attach Listener                      system            5           RUNNABLE    0.0         0.000        0:0.046     false       true
Memory                         used       total     max        usage     GC
heap                           2021M      3399M     3399M      59.46%    gc.ps_scavenge.count                 3387
ps_eden_space                  286M       425M      425M       67.26%    gc.ps_scavenge.time(ms)              106288
ps_survivor_space              217M       424M      424M       51.17%    gc.ps_marksweep.count                153
ps_old_gen                     1517M      2549M     2549M      59.54%    gc.ps_marksweep.time(ms)             8292
nonheap                        34M        35M       -1         96.97%
code_cache                     7M         8M        240M       3.27%
metaspace                      23M        24M       -1         97.47%
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:19:58 CST 2021/1741s

# -n 打印次数,这里打印3次
[arthas@10668]$ dashboard -n  3
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
1     main                                 main              5           TIMED_WAITI 0.0         0.000        1:40.421    false       false
-1    GC task thread#5 (ParallelGC)        -                 -1          -           0.0         0.000        1:36.390    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           0.0         0.000        1:36.250    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           0.0         0.000        1:36.140    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           0.0         0.000        1:35.359    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           0.0         0.000        1:35.250    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           0.0         0.000        1:35.234    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           0.0         0.000        1:35.031    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           0.0         0.000        1:34.640    false       true
-1    VM Thread                            -                 -1          -           0.0         0.000        0:5.812     false       true
-1    C1 CompilerThread3                   -                 -1          -           0.0         0.000        0:1.390     false       true
-1    C2 CompilerThread2                   -                 -1          -           0.0         0.000        0:0.906     false       true
-1    C2 CompilerThread1                   -                 -1          -           0.0         0.000        0:0.718     false       true
Memory                         used       total     max        usage     GC
heap                           2022M      3399M     3399M      59.51%    gc.ps_scavenge.count                 3581
ps_eden_space                  4M         425M      425M       1.00%     gc.ps_scavenge.time(ms)              112327
ps_survivor_space              64K        434688K   434688K    0.01%     gc.ps_marksweep.count                160
ps_old_gen                     2018M      2549M     2549M      79.18%    gc.ps_marksweep.time(ms)             8699
nonheap                        34M        35M       -1         97.61%
code_cache                     7M         8M        240M       3.33%
metaspace                      23M        24M       -1         97.74%
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:21:32 CST 2021/1835s
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#2 (ParallelGC)        -                 -1          -           7.49        0.375        1:35.406    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           7.17        0.359        1:35.593    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           6.86        0.343        1:34.984    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           6.55        0.328        1:36.718    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           6.24        0.312        1:35.562    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           6.24        0.312        1:36.562    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           6.24        0.312        1:35.671    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           6.24        0.312        1:36.453    false       true
1     main                                 main              5           TIMED_WAITI 5.61        0.281        1:40.703    false       false
-1    VM Thread                            -                 -1          -           0.31        0.015        0:5.828     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.015     false       true
4     Signal Dispatcher                    system            9           RUNNABLE    0.0         0.000        0:0.000     false       true
Memory                         used       total     max        usage     GC
heap                           1020M      3399M     3399M      30.01%    gc.ps_scavenge.count                 3591
ps_eden_space                  261M       425M      425M       61.40%    gc.ps_scavenge.time(ms)              112686
ps_survivor_space              241M       424M      424M       56.82%    gc.ps_marksweep.count                161
ps_old_gen                     517M       2549M     2549M      20.30%    gc.ps_marksweep.time(ms)             8759
nonheap                        34M        35M       -1         97.64%
code_cache                     8M         8M        240M       3.34%
metaspace                      23M        24M       -1         97.75%
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:21:37 CST 2021/1840s
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#4 (ParallelGC)        -                 -1          -           6.46        0.328        1:36.781    false       true
1     main                                 main              5           RUNNABLE    5.84        0.296        1:41.000    false       false
-1    GC task thread#7 (ParallelGC)        -                 -1          -           5.84        0.296        1:35.859    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           5.54        0.281        1:36.843    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           5.23        0.265        1:35.859    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           4.92        0.250        1:35.234    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           4.92        0.250        1:36.968    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           4.61        0.234        1:35.640    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           4.61        0.234        1:35.906    false       true
106   arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.3         0.015        0:0.593     false       true
-1    C1 CompilerThread3                   -                 -1          -           0.3         0.015        0:1.406     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.015     false       true
Memory                         used       total     max        usage     GC
heap                           1936M      3399M     3399M      56.96%    gc.ps_scavenge.count                 3602
ps_eden_space                  10M        425M      425M       2.41%     gc.ps_scavenge.time(ms)              113036
ps_survivor_space              424M       424M      424M       99.94%    gc.ps_marksweep.count                161
ps_old_gen                     1501M      2549M     2549M      58.91%    gc.ps_marksweep.time(ms)             8759
nonheap                        34M        35M       -1         97.81%
code_cache                     8M         8M        240M       3.36%
metaspace                      23M        24M       -1         97.81%
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:21:42 CST 2021/1845s
Process ends after 3 time(s).

# -n 和 -i 结合:打印3次,间隔1秒
[arthas@10668]$ dashboard -i 1000 -n  3
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
1     main                                 main              5           TIMED_WAITI 0.0         0.000        1:46.375    false       false
-1    GC task thread#1 (ParallelGC)        -                 -1          -           0.0         0.000        1:43.140    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           0.0         0.000        1:43.000    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           0.0         0.000        1:42.734    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           0.0         0.000        1:41.796    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           0.0         0.000        1:41.750    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           0.0         0.000        1:41.656    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           0.0         0.000        1:41.578    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           0.0         0.000        1:41.171    false       true
-1    VM Thread                            -                 -1          -           0.0         0.000        0:6.125     false       true
-1    C1 CompilerThread3                   -                 -1          -           0.0         0.000        0:1.421     false       true
-1    C2 CompilerThread2                   -                 -1          -           0.0         0.000        0:1.265     false       true
-1    C2 CompilerThread1                   -                 -1          -           0.0         0.000        0:0.718     false       true
Memory                         used       total     max        usage     GC
heap                           2533M      3399M     3399M      74.53%    gc.ps_scavenge.count                 3825
ps_eden_space                  19M        425M      425M       4.68%     gc.ps_scavenge.time(ms)              120045
ps_survivor_space              424M       424M      424M       99.94%    gc.ps_marksweep.count                169
ps_old_gen                     2089M      2549M     2549M      81.96%    gc.ps_marksweep.time(ms)             9228
nonheap                        35M        36M       -1         97.28%
code_cache                     8M         8M        240M       3.47%
metaspace                      23M        24M       -1         96.96%
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:23:31 CST 2021/1955s
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#4 (ParallelGC)        -                 -1          -           12.26       0.125        1:42.859    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           9.2         0.093        1:43.234    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           7.66        0.078        1:41.250    false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           7.66        0.078        1:41.828    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           7.66        0.078        1:41.656    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           7.66        0.078        1:41.875    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           6.13        0.062        1:41.718    false       true
-1    VM Thread                            -                 -1          -           4.6         0.046        0:6.171     false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           4.6         0.046        1:43.046    false       true
1     main                                 main              5           TIMED_WAITI 3.06        0.031        1:46.406    false       false
114   Timer-for-arthas-dashboard-bf73c6be- system            5           RUNNABLE    1.53        0.015        0:0.015     false       true
-1    C1 CompilerThread3                   -                 -1          -           1.53        0.015        0:1.437     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
Memory                         used       total     max        usage     GC
heap                           522M       3399M     3399M      15.36%    gc.ps_scavenge.count                 3826
ps_eden_space                  95M        425M      425M       22.49%    gc.ps_scavenge.time(ms)              120134
ps_survivor_space              0K         434688K   434688K    0.00%     gc.ps_marksweep.count                170
ps_old_gen                     426M       2549M     2549M      16.73%    gc.ps_marksweep.time(ms)             9304
nonheap                        35M        36M       -1         97.22%
code_cache                     8M         8M        240M       3.46%
metaspace                      23M        24M       -1         96.97%
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:23:32 CST 2021/1956s
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
1     main                                 main              5           TIMED_WAITI 7.69        0.078        1:46.484    false       false
-1    GC task thread#0 (ParallelGC)        -                 -1          -           7.69        0.078        1:41.906    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           7.69        0.078        1:41.953    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           6.15        0.062        1:43.109    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           6.15        0.062        1:42.921    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           4.61        0.046        1:41.765    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           4.61        0.046        1:41.296    false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           3.07        0.031        1:43.265    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           3.07        0.031        1:41.687    false       true
-1    C2 CompilerThread2                   -                 -1          -           1.53        0.015        0:1.281     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.015     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.015     false       true
4     Signal Dispatcher                    system            9           RUNNABLE    0.0         0.000        0:0.000     false       true
Memory                         used       total     max        usage     GC
heap                           1021M      3399M     3399M      30.03%    gc.ps_scavenge.count                 3828
ps_eden_space                  249M       425M      425M       58.56%    gc.ps_scavenge.time(ms)              120207
ps_survivor_space              254M       424M      424M       59.89%    gc.ps_marksweep.count                170
ps_old_gen                     517M       2549M     2549M      20.30%    gc.ps_marksweep.time(ms)             9304
nonheap                        35M        36M       -1         97.18%
code_cache                     8M         8M        240M       3.45%
metaspace                      23M        24M       -1         96.97%
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:23:33 CST 2021/1957s
Process ends after 3 time(s).

# thread 帮助
[arthas@10668]$ thread -h
USAGE:
   thread [--all] [-h] [-b] [--lockedMonitors] [--lockedSynchronizers] [-i <value>] [--state <value>] [-n <value>] [id]

SUMMARY:
   Display thread info, thread stack

EXAMPLES:
   thread
   thread 51
   thread -n -1
   thread -n 5
   thread -b
   thread -i 2000
   thread --state BLOCKED

WIKI:
   https://arthas.aliyun.com/doc/thread

OPTIONS:
     --all                                        Display all thread results instead of the first page
-h, --help                                       this help
-b, --include-blocking-thread                    Find the thread who is holding a lock that blocks the most number of threads.
     --lockedMonitors                             Find the thread info with lockedMonitors flag, default value is false.
     --lockedSynchronizers                        Find the thread info with lockedSynchronizers flag, default value is false.
-i, --sample-interval <value>                    Specify the sampling interval (in ms) when calculating cpu usage.
     --state <value>                              Display the thead filter by the state. NEW, RUNNABLE, TIMED_WAITING, WAITING, BLOCKED, TERMINAT
                                                  ED is optional.
-n, --top-n-threads <value>                      The number of thread(s) to show, ordered by cpu utilization, -1 to show all.
<id>                                             Show thread stack

# thread 命令
[arthas@13768]$ thread
Threads Total: 54, NEW: 0, RUNNABLE: 31, BLOCKED: 0, WAITING: 4, TIMED_WAITING: 4, TERMINATED: 0, Internal threads: 15
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#7 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.359     false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.234     false       true
-1    GC task thread#0 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.312     false       true
-1    GC task thread#1 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.171     false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.296     false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.203     false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           13.02       0.031        0:1.171     false       true
1     main                                 main              5           TIMED_WAITI 6.51        0.015        0:2.328     false       false
-1    GC task thread#5 (ParallelGC)        -                 -1          -           6.51        0.015        0:1.125     false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.000     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.000     false       true
4     Signal Dispatcher                    system            9           RUNNABLE    0.0         0.000        0:0.000     false       true
5     Attach Listener                      system            5           RUNNABLE    0.0         0.000        0:0.046     false       true
13    arthas-timer                         system            5           WAITING     0.0         0.000        0:0.000     false       true
15    Keep-Alive-Timer                     system            8           TIMED_WAITI 0.0         0.000        0:0.000     false       true
16    arthas-NettyHttpTelnetBootstrap-3-1  system            5           RUNNABLE    0.0         0.000        0:0.031     false       true
17    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
18    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
19    arthas-shell-server                  system            5           TIMED_WAITI 0.0         0.000        0:0.000     false       true
20    arthas-session-manager               system            5           TIMED_WAITI 0.0         0.000        0:0.000     false       true
21    arthas-UserStat                      system            5           WAITING     0.0         0.000        0:0.000     false       true
23    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.062     false       true
24    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.031     false       true
25    arthas-TermServer-1-1                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
26    arthas-TermServer-1-2                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
27    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
28    arthas-TermServer-1-3                system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
29    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
30    arthas-TermServer-1-4                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
31    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
32    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true

# thread ID :查看某个进行运行情况
[arthas@13768]$ thread 1
"main" Id=1 TIMED_WAITING
    at java.lang.Thread.sleep(Native Method)
    at java.lang.Thread.sleep(Thread.java:340)
    at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:386)
    at chapter03.JProfilerTest.main(JProfilerTest.java:15)

# -b:可查看死锁线程
[arthas@13768]$ thread -b
No most blocking thread found!

# 2 秒钟内CPU统计
[arthas@13768]$ thread -i 2000
Threads Total: 53, NEW: 0, RUNNABLE: 31, BLOCKED: 0, WAITING: 4, TIMED_WAITING: 3, TERMINATED: 0, Internal threads: 15
ID    NAME                                 GROUP             PRIORITY    STATE       %CPU        DELTA_TIME   TIME        INTERRUPTED DAEMON
-1    GC task thread#0 (ParallelGC)        -                 -1          -           4.65        0.093        0:13.343    false       true
-1    GC task thread#2 (ParallelGC)        -                 -1          -           4.65        0.093        0:13.234    false       true
-1    GC task thread#7 (ParallelGC)        -                 -1          -           3.87        0.078        0:13.484    false       true
-1    GC task thread#6 (ParallelGC)        -                 -1          -           3.87        0.078        0:13.015    false       true
-1    GC task thread#3 (ParallelGC)        -                 -1          -           3.87        0.078        0:13.156    false       true
-1    GC task thread#4 (ParallelGC)        -                 -1          -           3.87        0.078        0:12.781    false       true
1     main                                 main              5           TIMED_WAITI 3.1         0.062        0:17.500    false       false
-1    GC task thread#1 (ParallelGC)        -                 -1          -           3.1         0.062        0:13.218    false       true
-1    GC task thread#5 (ParallelGC)        -                 -1          -           3.1         0.062        0:13.031    false       true
2     Reference Handler                    system            10          WAITING     0.0         0.000        0:0.000     false       true
3     Finalizer                            system            8           WAITING     0.0         0.000        0:0.000     false       true
4     Signal Dispatcher                    system            9           RUNNABLE    0.0         0.000        0:0.000     false       true
5     Attach Listener                      system            5           RUNNABLE    0.0         0.000        0:0.046     false       true
13    arthas-timer                         system            5           WAITING     0.0         0.000        0:0.000     false       true
16    arthas-NettyHttpTelnetBootstrap-3-1  system            5           RUNNABLE    0.0         0.000        0:0.031     false       true
17    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
18    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
19    arthas-shell-server                  system            5           TIMED_WAITI 0.0         0.000        0:0.015     false       true
20    arthas-session-manager               system            5           TIMED_WAITI 0.0         0.000        0:0.015     false       true
21    arthas-UserStat                      system            5           WAITING     0.0         0.000        0:0.000     false       true
23    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.062     false       true
24    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.031     false       true
25    arthas-TermServer-1-1                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
26    arthas-TermServer-1-2                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
27    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
28    arthas-TermServer-1-3                system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
29    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.015     false       true
30    arthas-TermServer-1-4                system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
31    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
32    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.000     false       true
33    arthas-NettyWebsocketTtyBootstrap-4- system            5           RUNNABLE    0.0         0.000        0:0.015     false       true

# -n:CPU占用排名:这里显示出前4名
[arthas@13768]$ thread -n 4
"main" Id=1 cpuUsage=23.32% deltaTime=46ms time=23656ms TIMED_WAITING
    at java.lang.Thread.sleep(Native Method)
    at java.lang.Thread.sleep(Thread.java:340)
    at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:386)
    at chapter03.JProfilerTest.main(JProfilerTest.java:15)

"C1 CompilerThread3" [Internal] cpuUsage=7.77% deltaTime=15ms time=875ms

"Reference Handler" Id=2 cpuUsage=0.0% deltaTime=0ms time=0ms WAITING on java.lang.ref.Reference$Lock@766a610c
    at java.lang.Object.wait(Native Method)
    -  waiting on java.lang.ref.Reference$Lock@766a610c
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"Finalizer" Id=3 cpuUsage=0.0% deltaTime=0ms time=0ms WAITING on java.lang.ref.ReferenceQueue$Lock@257eba4e
    at java.lang.Object.wait(Native Method)
    -  waiting on java.lang.ref.ReferenceQueue$Lock@257eba4e
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值