1

I have a host and I am not sure about the memory utilization when comparing the output of the free command and the contents of /proc/meminfo. Buffers+Cache don't seem to match between the two sources.

[kbrandt@ny-chsearch01]~% free -k
              total        used        free      shared  buff/cache   available
Mem:       24506972    18074768      572836         124     5859368     5996392
Swap:       4194300      130044     4064256
[kbrandt@ny-chsearch01]~% cat /proc/meminfo 
MemTotal:       24506972 kB
MemFree:          575808 kB
MemAvailable:    5996136 kB
Buffers:            3140 kB
Cached:           380032 kB
SwapCached:        61344 kB
Active:         16305144 kB
Inactive:        1860568 kB
Active(anon):   15990712 kB
Inactive(anon):  1791952 kB
Active(file):     314432 kB
Inactive(file):    68616 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       4194300 kB
SwapFree:        4064256 kB
Dirty:                24 kB
Writeback:             0 kB
AnonPages:      17721372 kB
Mapped:            91608 kB
Shmem:               124 kB
Slab:            5472968 kB
SReclaimable:    5407820 kB
SUnreclaim:        65148 kB
KernelStack:        5568 kB
PageTables:        39784 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    16447784 kB
Committed_AS:   18211456 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      231460 kB
VmallocChunk:   34359310332 kB
HardwareCorrupted:     0 kB
AnonHugePages:  17414144 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       91968 kB
DirectMap2M:    25073664 kB

man free says:

buff/cache Sum of buffers and cache

However as you can see from the above output: free says buff/cache is 5859368, but the output of Buffers and Cached from /proc/meminfo is less.

Host is CentOS Linux release 7.4.1708 (Core) with kernel 3.10.0-693.21.1.el7.x86_64. Main consumer of memory on the host is elasticsearch (java).

Can anyone explain the discrepancy?

2

The memory is the 'Slab' section, after looking closer at the man page man free:

cache  Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo)

To learn more about the slab, see SlabInfo Manage Page:

SYNOPSIS: cat /proc/slabinfo

DESCRIPTION: Frequently used objects in the Linux kernel (buffer heads, inodes, dentries, etc.) have their own cache. The file /proc/slabinfo gives statistics on these caches.

So in general since it is cache, it is okay for the Slab to be filling up. The one area of concern might be if a large amount if not reclaimable (SUnreclaim). This can be viewed in /proc/meminfo:

[root@ny-chsearch01 ~]# grep -i S.*recl /proc/meminfo 
SReclaimable:    5320344 kB
SUnreclaim:        64756 kB

If one is looking to estimate free memory then the newer 3.14 kernel has a MemAvailable metric in /proc/meminfo which is a more accurate estimate than the older Total-Buffer-Cache, see How can I get the amount of available memory portably across distributions? for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.