jvm调试工具arthas的vmtool命令获取内存中的类实例信息

vmtool 利用JVMTI接口,实现查询内存对象,强制GC等功能。

获取对象

[arthas@25435]$ vmtool --action getInstances --className com.demo.entity.StudentInfo --limit 10
@StudentInfo[][
    @StudentInfo[com.demo.entity.StudentInfo@68082dfb],
    @StudentInfo[com.demo.entity.StudentInfo@1fb1c17d],
    @StudentInfo[com.demo.entity.StudentInfo@335c916b],
]

通过上述命令,可以看出,内存中存在3个StudentInfo对象实例。 

指定返回结果展开层数

getInstances action返回结果绑定到instances变量上,它是数组。

通过 -x/--expand 参数可以指定结果的展开层次,默认值是1。

[arthas@25435]$ vmtool --action getInstances --className com.demo.entity.StudentInfo --limit 10 -x 2
@StudentInfo[][
    @StudentInfo[
        userId=@Long[100],
        userName=@String[XXX],
        userNo=@String[14242919900721123X],
        schoolNo=@String[10000114],
        accountBalance=null,
        currSelect=@Boolean[false],
        orgNo=@String[70],
        loginName=null,
    ],
    @StudentInfo[
        userId=@Long[558],
        userName=@String[YYY],
        userNo=@String[152827197801154222],
        schoolNo=@String[10000114],
        accountBalance=null,
        currSelect=@Boolean[false],
        orgNo=@String[70],
        loginName=null,
    ],
    @StudentInfo[
        userId=@Long[100],
        userName=@String[ZZZ],
        userNo=@String[14242919900721123X],
        schoolNo=@String[10000114],
        accountBalance=null,
        currSelect=@Boolean[false],
        orgNo=@String[70],
        loginName=null,
    ],
]

通过指定对象的展开层次,可以看到对象的基本数据类型值。这对于调试程序有很大的帮助,尤其是在测试环境或生产环境出现异常情况时。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿20

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值