综述
slab使用cache-slab-object三级方式管理从伙伴系统批发过来的物理内存。
slab到底批发了多少内存,有一些方式可以查看:
- cat /proc/meminfo
- nmon的m菜单
定义问题
某些场景我们需要获取slab使用的物理内存大小,有哪些方式可以获取
- cat /proc/meminfo
- nmon的m菜单
方法一:/proc/meminfo查看
方法二:nmon的方式获取slab总物理内存大小
nmon介绍
是什么:一个系统监控运维神器
nmon - systems administrator, tuner, benchmark tool.
详细介绍:
nmon is is a systems administrator, tuner, benchmark tool. It can display the CPU, memory, network,
disks (mini graphs or numbers), file systems, NFS, top processes, resources (Linux version & processors)
and on Power micro-partition information.
安装 nmon
apt install nmon
查看slab内存: nmon
进入nmon
nmon
输入m进入m统计
可以看到图中Slab的大小用了53.9M的物理内存
和前面通过 /proc/meminfo获取相同
其他
nmon是系统监控神器,值得以后深入研究
综述
slab分配的物理内存可以通过系统提供的proc文件系统,也可以通过nmon工具
参考
https://www.modb.pro/db/55909