One. Clear concept
- A buffer is something that have yet to being "written" to disk.
- A cache is something that have been "read" from the disk and stored for later use.
That is, buffer is used to store the data to be output to disk (block device), and the cache is to store the data read from disk. Both are designed to improve IO performance and are managed by the OS.
Two. Command output
Total used free shared buffers cachedmem: 16436916 16285096 151820 0 243504 6831584-/+ buffers/cache: 9210008 7226908Swap: 8224760 4160 8220600
1. men:total = men:used + men:free
2. The third line indicates
- -buffers/cache, which indicates how much memory an application thinks the system is using;
- +buffers/cache, which indicates how much memory an application thinks the system has;
Equation:-buffers/cache = mem:used-men:buffers-men:cached
+buffers/cache = Men:free + men:buffers-men:cached
3. The memory that is shared by several processes is now deprecated and its value is always 0 (it may not be 0 on some systems, depending on how the free command is implemented).
What is Shared Memory?
Output of the free command on Linux