当前我们系统(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)