The memory usage reported in cgroup differs from the free command

8,421

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.

Share:
8,421

Related videos on Youtube

offbynull
Author by

offbynull

Updated on September 18, 2022

Comments

  • offbynull
    offbynull almost 2 years

    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.

  • davidparks21
    davidparks21 almost 3 years
    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.
  • Vlad Frolov
    Vlad Frolov almost 3 years
    @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