Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

free memory #415

Open
1337newbee opened this issue Feb 16, 2016 · 2 comments
Open

free memory #415

1337newbee opened this issue Feb 16, 2016 · 2 comments

Comments

@1337newbee
Copy link

Linux Memory Calculation

                free_mem = (memstats['MemFree'] - memstats['Buffers']) + memstats['Cached']

Isn't free memory calculated as below?

free-mem=(memstats['MemFree'] - memstats['Buffers']) - memstats['Cached']

@madflojo
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants