On a linux system, while using "free", following are the values:
total used free shared buff/cache available
Mem: 26755612 873224 389320 286944 25493068 25311948
Swap: 0 0 0
The total, used and free values don't add up. I'm expecting total = used + free.
Question: What am I missing here?
For the main memory, the actual size of memory can be calculated as
used+free+buffers+cache
ORused+free+buffers/cache
becausebuffers/cache = buffer+cache
.The man page of
free
highlightsused
asUsed memory (calculated as total - free - buffers - cache)
As the man page of free says :-
In your case,
Linux likes to cache every file that it opens. Every time you open a file for reading, Linux will cache it but it will drop those caches if it needs the memory for something more important -- like when a process on the system wants to allocate more memory. These caches in memory simply make Linux faster when the same files are used over and over again. Instead of actually going to disk every time it wants to read the file, it just gets it from memory and memory is a lot faster that disk. That is why your system shows 25493068 used in buff/cache but also shows 25311948 available. Much of that cached data can be freed if the system needs it.