当前我们系统(Centos7)内存占用率计算方式是由/proc/meminfo文件计算所得:memUsed = MemTotal - MemFree - Buffers- Cached
今天局点一个服务器产生告警,显示内存使用率已达到90%,free -k查看才30%左右,所以着手排查内存占用问题。
一、/proc/meminfo 计算used与free -k 差距大的原因
1、首先free命令的解释:
free displays the total amount of free and used physical and swap
memory in the system, as well as the buffers and caches used by the
kernel. The information is gathered by parsing /proc/meminfo. The
displayed columns are:
total Total installed memory (MemTotal and SwapTotal in
/proc/meminfo)
used Used memory (calculated as total - free - buffers - cache)
free Unused memory (MemFree and SwapFree in /proc/meminfo)
shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)
buffers
Memory used by kernel buffers (Buffers in /proc/meminfo)
cache Memory used by the page cac

本文介绍了Linux系统中/proc/meminfo计算内存使用与free命令显示差距大的原因,主要关注Slab内存分配器的作用。Slab用于小对象缓存,减少内存分配次数。当差距较大时,可通过/proc/slabinfo或slabtop检查Slab占用,并谨慎调整系统参数如drop_caches和min_free_kbytes。分析Slab占用可借助systemTap工具。
最低0.47元/天 解锁文章
220

被折叠的 条评论
为什么被折叠?



