Usually we all have confusion regarding the amount of free memory available while running the command free -m. In the following example
total used free shared buffers cached
Mem: 72348 71972 375 0 6242 41377
-/+ buffers/cache: 24352 47995
Swap: 4095 1309 2786
In the above result, from the top line we can see that out of 72GB available 71GB is being used, but we don’t see any such high memory usage in the server. But you can see lot of memory in cached. The actual memory is being used is in the disk cache. Cached memory is essentially free, so that it can be quickly taken if a running (or newly starting) program needs the memory.
The reason Linux uses so much memory for disk cache is because the RAM is wasted if it isn’t used. Keeping the cache means that if something needs the same data again, there’s a good chance it will still be in the cache in memory. Fetching the information from there is around 1,000 times quicker than getting it from the hard disk. If it’s not found in the cache, the hard disk needs to be read anyway.
The -/+ buffers/cache line shows how much memory is used and free from the perspective of the application.
The difference between buffers and cache –> Buffers are associated with a specific block device, and cover caching of filesystem metadata as well as tracking in-flight pages. The cache only contains parked file data.
That is, the buffers remember what’s in directories, what file permissions are, and keep track of what memory is being written from or read to for a particular block device. The cache only contains the contents of the files themselves.