I just launched a new ubuntu machine. available memory is reasonable but free mem is very small:

cat /proc/meminfo |more
MemTotal:        2034484 kB
MemFree:          703496 kB
MemAvailable:    1538076 kB
Buffers:           80332 kB
Cached:           829408 kB

How should I calculate used_memory? According to https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop

Used_mem = Total_mem- Free_mem

which does not make sense me because if I used this equation, the machine already used a lot of although it has not run anything yet. I feel maybe

Used_mem = Total_mem- Available_mem 

make more sense to me.

So my question is: how to calculate used memory? Or How to calculate memory which is really free to use? the free memory shown at above must not be correct.

Note I am calculate used_memory using node_exporter metrics.


1 Answer 1


Look at the man page of the free command:

free  displays the total amount of free and used physical and swap mem‐
       ory in the system, as well as the buffers and caches used by  the  ker‐
       nel.  The  information  is  gathered by parsing /proc/meminfo. The dis‐
       played 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)

  • Thanks fich: look like free + buffer + cache = 1613236 kb is close to available memory = 1538076 kb and I guess the difference is due to some memory is reserved by system. so I feel the really used memory should be (total - available)
    – user389955
    Dec 10, 2020 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .