memory usage of linux - aragorn/home GitHub Wiki
JK checked this in year 2012. But I assume, still most things are valid.
How to find out actual free or available memory of linux?
$ free; sync; echo 3 > /proc/sys/vm/drop_caches; free;
$ grep -E 'MemFree|Inactive' /proc/meminfo;
# example
root@sheldon:~# free; sync; echo 3 > /proc/sys/vm/drop_caches; free;
total used free shared buff/cache available
Mem: 16425092 10227228 4915028 42528 1282836 5732788
Swap: 0 0 0
total used free shared buff/cache available
Mem: 16425092 10227292 5938192 42528 259608 5835264
Swap: 0 0 0
root@sheldon:~# grep -E 'MemFree|Inactive' /proc/meminfo;
MemFree: 5936952 kB
Inactive: 62144 kB
Inactive(anon): 40692 kB
Inactive(file): 21452 kB
root@sheldon:~#
Articles on linux memory
- http://stackoverflow.com/questions/658411/entries-in-proc-meminfo/6886706#6886706
- http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt
Generally,
MemTotal = MemFree + Active + Inactive + Slab + PageTables + VmallocUsed + X =~ MemFree + Active + Inactive + Slab + PageTables + VmallocUsed
Active + Inactive =~ Buffers + Cached + SwapCached + AnonPages
MemAvail : Amount of memory that user application can demand and get allocated in physical memory. =~ MemFree + Inactive
MemUsed by user and kernel = MemTotal - MemAvail = MemTotal - MemFree - Inactive =~ Active + Slab + PageTables + VmallocUsed
MemUsed by user =~ Active + VmallocUsed
MemUsed by kernel =~ Slab + PageTables