Re: where did all my memory go?

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Wed, 16 Feb 2005 13:54:32 -0800 (PST)
On 16 Feb, Damian Gerow wrote:
> Thus spake Eric Anderson (anderson_at_centtech.com) [16/02/05 16:02]:
> : >On a system that has been up for any significant time, free memory
> : >should be very small since free memory is wasted.  My guess is that it
> : >is disk cache and that one of the nightly jobs accessed enough stuff to
> : >fill it.
> : 
> : Speaking of this - is there a way to flush the disk cache?  
> 
> sync(8)?

That only causes the dirty pages to be written back to the disks, which
happens within about 30 seconds automagically.  The data will still be
cached, but the dirty bit on each page will be cleared until the page is
written again.

If you really want to make the "free memory" count go back up, write a
small C program that mallocs a large amount of memory, and writes to
each page, and then exits.  When you run this program, it will steal
memory from the inactive pool, and release it back to the free list when
the process exits.  The reason that the memory is returned to the free
list in this case is because the memory is known to not contain data
that can be reused.  This is a fairly useless thing to do because any
user process that needs physical RAM can just as easily allocated it
from the inactive pool as from the free pool, and as others have noted,
the cached data in the inactive pool might be reused, saving some disk
I/O.
Received on Wed Feb 16 2005 - 20:54:50 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:28 UTC