Arthas 的 sc 命令和 sm 命令实战

一 点睛

sc:查看 JVM 已加载的类信息。
https://arthas.aliyun.com/doc/sc.html
sm:查看已加载类的方法新。
https://arthas.aliyun.com/doc/sm.html

二 代码

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.

四 实战

# sc 查看 JVM 已加载的类信息。
[arthas@13768]$ sc chapter03.Data
chapter03.Data
Affect(row-cnt:1) cost in 4 ms.

# 通配查找
[arthas@13768]$ sc chapter03.*
chapter03.Data
chapter03.JProfilerTest
Affect(row-cnt:2) cost in 6 ms.

# 查看加载类的详细信息
[arthas@13768]$ sc -d 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值