LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-18-2010, 07:33 AM   #1
brgsousa
Member
 
Registered: Aug 2007
Location: Salvador, Brazil
Distribution: Debian, Ubuntu
Posts: 185

Rep: Reputation: 15
free, buff, cache memory on Debian


Hi,
What it's the difference between buff(ered) and cache portions of memory?

Code:
# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 1399208  16760 143932    0    0    47    56  525  190  9  1 88  3
regards
 
Old 06-18-2010, 10:33 AM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
From wikipedia
Quote:
The terms "buffer" and "cache" are not mutually exclusive and the functions are frequently combined; however, there is a difference in intent.[citation needed] A buffer is a temporary memory location, that is traditionally used because CPU instructions cannot directly address data stored in peripheral devices. Thus, addressable memory is used as intermediate stage.

Additionally such a buffer may be feasible when a large block of data is assembled or disassembled (as required by a storage device), or when data may be delivered in a different order than that in which it is produced. Also a whole buffer of data is usually transferred sequentially (for example to hard disk), so buffering itself sometimes increases transfer performance or reduce the variation or jitter of the transfer's latency as opposed to caching where the intent is to reduce the latency. These benefits are present even if the buffered data are written to the buffer once and read from the buffer once.

A cache also increases transfer performance. A part of the increase similarly comes from the possibility that multiple small transfers will combine into one large block. But the main performance-gain occurs because there is a good chance that the same datum will be read from cache multiple times, or that written data will soon be read. A cache's sole purpose is to reduce accesses to the underlying slower storage. Cache is also usually an abstraction layer that is designed to be invisible from the perspective of neighbouring layers.
If you're looking for memory that's free for application use, I typically use free -lm and read the line that begins with "-/+ buffers/cache".
 
Old 06-18-2010, 11:51 AM   #3
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,044

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
Quote:
Originally Posted by pljvaldez View Post
I don't think that generic answer is very effective for this Linux question.

That Wikipedia page looked like it was influenced by the meanings of buffer vs. cache that are specific to Linux. But it certainly wasn't focused on those meanings.

My understanding/recall of what I've read on this question (but don't remember where) is:

Cache holds only aligned page size chunks of files. Buffers are used in various situations in which aligned page size chunks of files are not practical. I think the buffers are tied to chunks of the media (the partition for a typical filesystem) rather than chunks of a specific file.

But don't trust me on the above, because I'm not sure I trust the pages I read that gave me that info and I'm not sure I understood/recall them accurately. So I'm just posting this while we wait for someone who actually knows to post something more accurate.
 
Old 06-18-2010, 11:56 AM   #4
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by johnsfine View Post
I don't think that generic answer is very effective for this Linux question.
I should probably start putting a general disclaimer on anything I quote from wikipedia. After all, it is an imperfect reference...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like to understand the linux "free" command with respect to cache and free memory bruzzese Linux - Server 2 03-28-2010 12:52 PM
[SOLVED] Linux memory free vs buff avtandil_k Linux - Newbie 4 02-22-2010 09:21 PM
how to free the cache memory? adamruss Linux - General 5 08-25-2007 11:36 AM
increase free physical memory, decrease disk cache efm Linux - Hardware 4 03-30-2006 09:53 AM


All times are GMT -5. The time now is 09:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration