5

Why would the free command be reporting a much different mem usage number vs cgroup?

$ free -b 
              total        used        free      shared  buff/cache   available
Mem:     2096914432   520863744  1112170496    35389440   463880192  1356828672
Swap:    2145382400           0  2145382400

$ cat /sys/fs/cgroup/memory/memory.usage_in_bytes 
857239552

The documentation for cgroups says that memory.usage_in_bytes is a "fuzz value". I'm guessing that just means it reports an estimate that's close to the actual value. Even if it's an estimate, I don't think it should be this far off.

I'm running Linux Mint 18.2 in a VirutalBox VM.

offbynull
  • 203
  • 2
  • 7

1 Answers1

4

memory.usage_in_bytes and memory.max_usage_in_bytes report RSS+CACHE, so in terms of your free output:

memory.usage_in_bytes ~= free.used + free.(buff/cache) - (buff)

You may also be interested in /sys/fs/cgroup/memory/memory.stat, though I still couldn't find/compute the free.used value from the /sys/fs/cgroup/memory/memory.stat output.

Vlad Frolov
  • 536
  • 4
  • 5
  • What's the difference between `free.(buff/cache)` and `(buff)` in this answer? It's not clear where you're getting the `(buff)` value from. `free.used` and `free.(buff/cache)` are clearly from the output of running `free`. – davidparks21 Jul 14 '21 at 02:06
  • 1
    @davidparks21 as far as I recall, the thing is that you cannot find pure `(buff)`, but `memory.usage_in_bytes` seems to only include the cache – Vlad Frolov Jul 14 '21 at 06:45