From owner-freebsd-questions Thu Jul 13 14:16:55 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 5E81A37B50E; Thu, 13 Jul 2000 14:16:47 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id QAA13871; Thu, 13 Jul 2000 16:16:37 -0500 (CDT) (envelope-from dan) Date: Thu, 13 Jul 2000 16:16:36 -0500 From: Dan Nelson To: Ben Smithurst Cc: Glenn McCalley , freebsd-questions@FreeBSD.org Subject: Re: what is soaking up memory? Message-ID: <20000713161636.A13414@dan.emsphone.com> References: <20000713093805.A20695@dan.emsphone.com> <20000713210418.K48641@strontium.scientia.demon.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline User-Agent: Mutt/1.3.5i In-Reply-To: <20000713210418.K48641@strontium.scientia.demon.co.uk>; from "Ben Smithurst" on Thu Jul 13 21:04:18 GMT 2000 X-OS: FreeBSD 5.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In the last episode (Jul 13), Ben Smithurst said: > Dan Nelson wrote: > > Free memory is wasted memory. The RAM that your programs don't > > actively allocate is used by FreeBSD as disk cache. Inact, Cache, > > and Buf are all cached data at different aging levels. You > > actually want as little Free memory as possible. > > I think I'll add this question, with your answer, to the FAQ. This > question is becoming a FAQ, after all... I'm attaching an email Paul Herman sent to be about this; it goes into a bit more detail, and actually makes sense. -- Dan Nelson dnelson@emsphone.com --sm4nu43k4a2Rpi4c Content-Type: message/rfc822 Content-Disposition: inline Return-Path: Received: from gatekeeper.emsphone.com (root@gatekeeper.emsphone.com [199.67.51.100]) by dan.emsphone.com (8.9.3/8.9.3) with ESMTP id KAA03938 for ; Thu, 13 Jul 2000 10:50:33 -0500 (CDT) (envelope-from pherman@frenchfries.net) Received: from mail2.netcologne.de (mail2.netcologne.de [194.8.194.103]) by gatekeeper.emsphone.com (8.10.1/8.10.1) with ESMTP id e6DFoWU17040 for ; Thu, 13 Jul 2000 10:50:32 -0500 Received: from bagabeedaboo.security.at12.de (dial-195-14-254-57.netcologne.de [195.14.254.57]) by mail2.netcologne.de (8.9.3/8.9.3) with ESMTP id RAA08103 for ; Thu, 13 Jul 2000 17:50:29 +0200 (MET DST) Received: from localhost (localhost.security.at12.de [127.0.0.1]) by bagabeedaboo.security.at12.de (8.10.2/8.10.2) with ESMTP id e6DFnDM02156 for ; Thu, 13 Jul 2000 17:49:13 +0200 (CEST) Date: Thu, 13 Jul 2000 17:49:13 +0200 (CEST) From: Paul Herman Sender: pherman@bagabeedaboo.security.at12.de To: Dan Nelson Subject: Re: what is soaking up memory? In-Reply-To: <20000713100917.C20695@dan.emsphone.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi Dan, This whole active thing bit me about a week ago on a different thread, but that was because there are about 3 different definitions of "active" memory -- so it's still fresh in my head. Here, we are both talking about top, so there won't be any confusion... On Thu, 13 Jul 2000, Dan Nelson wrote: > > Perhaps I read it wrong, but he said 125MB Active. > > Active is cached memory also :) Since under FreeBSD, the VM and disk > subsystems are the same, all allocated memory is "cached". If the > paging/caching algorithm decides that a page is too old, it checks to > see where the page came from. If it's backed by a disk file, it just > frees the page. If it's malloced memory, it dumps the page to swap. Pretty close. Active memory are physical pages in memory that are currently referenced by a program. Period. There can be more than one reference, in which case you would say the page is "shared", but I think "cached" would be the wrong term. When the page is freed by the program (i.e. reference count goes to zero) it gets bumped down into "Inactive" if the page is dirty, or into the "Cache" bucket if it's clean. That's all. No magic. But... Periodicaly, especially if the system is low on memory, it starts cleaning dirty pages in the "Inactive" queue, and moves them into the "Cache" bucket (the number of these pages is the "pdpgs" statistic in systat(1)). I think that is what Dave Greenman was talking about, but bear in mind, if you system isn't starved for memory, then it won't move any pages from Inact -> Cache. So, I don't think you can pin it down to just a matter of seconds. You're right, Buf is just a cache for filesystem nodes, and isn't a part of this system. Neither is Wired, for that matter. What *is* based on a matter of seconds (which is what bit me in another thread) is the "active" memory shown by vmstat. This is memory that has been accesed by a program in the last 20 seconds. Whew! :) -Paul. P.S. If you think this is useful, you can post it to the list, but I think it's basically convered in the handbook section "FreeBSD VM Internals" --sm4nu43k4a2Rpi4c-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message