This is an old question that I've seen from time to time. My understanding of it is rather limited (having read about the differences a long time ago, but the factoid(s) involved never really stuck).

As I understand it,

  • Buffers

    Are used by programs with active I/O operations, i.e. data waiting to be written to disk

  • Cache

    Is the result of completed I/O operations, i.e. buffers that have been flushed or data read from disk to satisfy a request.

Can I get a clear explanation for posterity?

link|improve this question

feedback

3 Answers

up vote 15 down vote accepted

The "cached" total will also include some other memory allocations, such as any tmpfs filesytems. To see this in effect try:

mount -ttmpfs none t
dd if=dev/zero of=t/zero.file bs=10240 count=10240
sync; echo 3 > /proc/sys/vm/drop_caches; free -m
umount t
sync; echo 3 > /proc/sys/vm/drop_caches; free -m

and you will see the "cache" value drop by the 100Mb that you copied to the ram-based filesystem (assuming there was enough free RAM, you might find some of it ended up in swap if the machine is already over-committed in terms of memory use). The "sync; echo 3 > /proc/sys/vm/drop_caches" before each call to free should write anything pending in all write buffers (the sync) and clear all cached/buffered disk blocks from memory so free will only be reading other allocations in the "cached" value.

The RAM used by virtual machines (such as those running under VMWare) will also be counted in free's "cached" value, as will RAM used by currently open memory-mapped files.

So it isn't as simple as "buffers counts pending file/network writes and cached counts recently read/written blocks held in RAM to save future physical reads", though for most purposes this simpler description will do.

link|improve this answer
1  
+1 for interesting nuances. This is the kind of information I'm looking for. In fact, I suspect that the figures are so convoluted, so involved in so many different activities, that they are at best general indicators. – Avery Payne Jun 10 '09 at 17:49
feedback

Tricky Question. When you calculate free space you actually need to add up buffer and cache both. This is what I Could find

A buffer is something that has yet to be "written" to disk. A cache is something that has been "read" from the disk and stored for later use.

http://visualbasic.ittoolbox.com/documents/difference-between-buffer-and-cache-12135

link|improve this answer
feedback

Check this page out

link|improve this answer
3  
That page doesn't really answer the question... – freiheit Jun 10 '09 at 16:30
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.