Further memory question [was: Clear the computer's memory?]

Dave Carrigan dave at rudedog.org
Thu Mar 30 17:03:01 UTC 2006

On Thursday 30 March 2006 08:01, R Kimber wrote:
> Are you saying that it takes maybe 24 hours for the kernel to work out
> which memory it can use for buffers and whatever?  I assumed that it
> would do this straight away and just dynamically release memory as I
> start up apps.

No no no no no no no no no.

The kernel uses all available memory for buffers. This is dynamic. If you have 
2G of memory and your working set of programs is using .7G then the kernel 
will use 1.3G for buffers. If your working set grows to 1.4G then the kernel 
will use .6G for buffers. If your working set subsequently shrinks to .2G 
because you logged off then the kernel will use 1.8G for buffers.

In addition, the kernel does not technically allocate memory in the same sense 
that a program has to. The kernel already owns all memory in the system so it 
just has to earmark each page according to what it's to be used for. If the 
kernel needs a buffer, it looks for a page that hasn't been earmarked for 
anything else, and uses it as a buffer. If there are no pages because the 
programs have used them all then the kernel won't be able to use any for a 

Finally, the kernel does not release buffers for no reason. Once a file has 
been read, its data is going to be in that buffer for as long as possible, 
even if the original process has exited, and even if the original file has 
been deleted. The kernel will release a buffer only when something else needs 
the memory. Then it will find a page with the oldest data and earmark it for 
the new use (which of course could be just another buffer to cache new file 

If you have lots of memory and very few programs running, it's very possible 
that there could be memory pages containing hours- or even days-old data in 
them [ignoring that the nightly locate command will pretty much refresh every 
buffer page because it reads so much data].

But the bottom line is that after a few hours of running programs that are 
doing any kind of I/O, all available the memory on the system is going to be 
used for something.

Dave Carrigan
Seattle, WA, USA
dave at rudedog.org | http://www.rudedog.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060330/2d7aef7f/attachment.pgp>

More information about the ubuntu-users mailing list