Open 1337newbee opened 8 years ago
Actually it's Free + Buffers + Cached not sure what I was thinking of with the - Buffers
.
$ free -m
total used free shared buffers cached
Mem: 5962 5174 788 0 62 2370
-/+ buffers/cache: 2740 3222
Swap: 16383 3840 12543
If you look at the above it shows on the second line 3222
which is 788 + 62 + 2370
(giving a little leeway for rounding). Basically the way it works is this, when Linux has memory to spare it uses it for caching filesystem contents and frequently accessed data. When the free (non-cached) memory starts to go below the vm.min_free_kbytes
tunable the Kernel will start deallocating the cache and using the freed up memory.
Thanks for calling this out not sure why I put a -
there I totally should know better.
I agree. It should be free+Buffers+Cached - Check this documentation from Redhat https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/chap-Oracle_9i_and_10g_Tuning_Guide-Memory_Usage_and_Page_Cache.html
Linux Memory Calculation
Isn't free memory calculated as below?
free-mem=(memstats['MemFree'] - memstats['Buffers']) - memstats['Cached']