DOYENSYS Knowledge Portal

We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal

Thursday, January 29, 2015

How To Properly Check System Memory Usage on Linux

To the casual observer, the output of some performance monitor utilities appear to report that system memory is almost all used up, with almost no free memory. For example:

$ free
             total       used       free     shared    buffers     cached
Mem:       3083104    2960224     122880       9708     131964    1491888
-/+ buffers/cache:    1336372    1746732
Swap:      2113532        196    2113336

It seems that memory is almost completely used:

used / total == 2960224 / 3083104 * 100 == 96%

Fortunately, this is not the case. The mistake is in not realizing Linux uses spare memory to cache disk data likely to be used again. The simplistic calculation ignores this; the proper calculation is:

(free+buffers+cached) / total * 100 == (122880+131964+1491888) / 3083104 == 56.7%

Taking this cached data into account, the calculation reveals the system is actively using less than 57^% and is certainly not under any memory stress.
Had this machine been under memory pressure, the cached category could rapidly be reused, and the buffers category could be reused after having been flushed to the backing store.

No comments: