From owner-freebsd-current@FreeBSD.ORG Wed Feb 16 21:54:50 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0104516A4CF for ; Wed, 16 Feb 2005 21:54:50 +0000 (GMT) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7C0D43D31 for ; Wed, 16 Feb 2005 21:54:49 +0000 (GMT) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.1/8.13.1) with ESMTP id j1GLsWe3028017; Wed, 16 Feb 2005 13:54:36 -0800 (PST) (envelope-from truckman@FreeBSD.org) Message-Id: <200502162154.j1GLsWe3028017@gw.catspoiler.org> Date: Wed, 16 Feb 2005 13:54:32 -0800 (PST) From: Don Lewis To: dgerow@afflictions.org In-Reply-To: <20050216210629.GB718@afflictions.org> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: current@FreeBSD.org Subject: Re: where did all my memory go? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2005 21:54:50 -0000 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.