Date: Wed, 16 Feb 2005 13:54:32 -0800 (PST) From: Don Lewis <truckman@FreeBSD.org> To: dgerow@afflictions.org Cc: current@FreeBSD.org Subject: Re: where did all my memory go? Message-ID: <200502162154.j1GLsWe3028017@gw.catspoiler.org> In-Reply-To: <20050216210629.GB718@afflictions.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 16 Feb, Damian Gerow wrote: > Thus spake Eric Anderson (anderson@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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502162154.j1GLsWe3028017>