Striveonger

vuePress-theme-reco Mr.Lee    2015 - 2026
Striveonger Striveonger
主页
分类
  • 笔记
  • 文章
  • 工具
  • 读书/工具
标签
时间轴
简历
author-avatar

Mr.Lee

277

Article

147

Tag

主页
分类
  • 笔记
  • 文章
  • 工具
  • 读书/工具
标签
时间轴
简历

使用Arthas查看Map.size()

vuePress-theme-reco Mr.Lee    2015 - 2026

使用Arthas查看Map.size()

Mr.Lee 2026-04-16 23:52:33 Spring BootArthas

有需求, 想看下线上环境中的某个map的大小, 然后就想到的Arthas.

# 1. 获取SpringIOC中管理的所有类名
[arthas@1]$ vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBeanDefinitionNames()'
@String[][
...
    @String[userRocketMQConsumerManager],
...
]
# 2. 获取SpirngIOC中的userRocketMQConsumerManager实例, 然后就是取 userConsumerMap 的大小了
[arthas@1]$ vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("userRocketMQConsumerManager").userConsumerMap.size()'
@Integer[147]
[arthas@1]$ 
1
2
3
4
5
6
7
8
9
10
11

我已经开始好奇, Arthas 是怎么做到的了. userConsumerMap 是私有的呀...