From owner-freebsd-hackers Tue Mar 20 9: 6: 5 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.enteract.com (mail.enteract.com [207.229.143.33]) by hub.freebsd.org (Postfix) with ESMTP id D685937B719 for ; Tue, 20 Mar 2001 09:06:01 -0800 (PST) (envelope-from dscheidt@tumbolia.com) Received: from shell-2.enteract.com (dscheidt@shell-2.enteract.com [207.229.143.41]) by mail.enteract.com (8.11.1/8.11.2) with ESMTP id f2KH5tG40547; Tue, 20 Mar 2001 11:05:55 -0600 (CST) (envelope-from dscheidt@tumbolia.com) Date: Tue, 20 Mar 2001 11:05:54 -0600 (CST) From: David Scheidt X-Sender: dscheidt@shell-2.enteract.com To: sean-freebsd-hackers@chittenden.org Cc: freebsd-hackers@freebsd.org Subject: Re: Easy way to compute memory stats? (procfs?) In-Reply-To: <20010319223303.K84536@rand.tgd.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 19 Mar 2001 sean-freebsd-hackers@chittenden.org wrote: :> : Is there an easy way (from script ideally) to get the following :> :stats: :> : :> :free physical mem (avail ram) :> :> has a reasonable uptime. The VM system will cache things unless :> there's a demand for memory. vm.stats.vm.v_free_count has the value : : Drat. I was hoping to arrive at a number similar to top's :Free column. Right now the vm stat from sysctl is about 25% of what :top's reporting (256MB physical). At the same time... the free pages :may be a good value for me to toss around given that I'm also :including the load and some statistics of the host's past. The sysctl MIB vm.stats.vm.v_free_count has the same value as top's Free Column. (In pages) It's just not a very useful number. The machine I'm sitting at has 213 pages free, but it's not in any danger of running out of memory. The only times there will be lots of free memory are at system startup, when the memory has never been used, and if a large process exits, freeing its memory. (Quiting Netscape brought my free pages to 13139) : :> :free swap :> :> pstat(8) will tell you this : : Duh, thanks. : :> :total avail mem :> :> Do you mean physical memory, in which case the value of hw.physmem will :> tellyou. : : Phys mem + swap, which I think I can calc pretty easily now :that I have swap. -sc Well, not all memory is swapable, nor is all memory swap backed. Exectuable text sections are backed by the disk file, as it's much faster to just throw them away, reading them from disk if they're needed again, then it is to write them to swap and read them back from there. The same thing is true of files that have been mmaped -- the memory used is backed by the disk file, not swap. The available memory is higher than physical memory + swap. The usable memory is often less than physical memory + swap, as well. This box has 256MB RAM, and 756MB swap. Most of the time, if swap is being touched at all, there's something broken, and the machine is not very useable. However, if I've got something like a huge Netscape process, that's idle, and then start working with something else that uses masses of memory, the idle Netscape can get swapped out, and have 150MB of swapped used, and a box that is its normal zippy self. -- dscheidt@tumbolia.com Bipedalism is only a fad. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message