From owner-freebsd-stable@FreeBSD.ORG Sun Oct 14 20:34:23 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51A4516A41B for ; Sun, 14 Oct 2007 20:34:23 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 104F013C458 for ; Sun, 14 Oct 2007 20:34:22 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.1/8.14.1) id l9EKYLSR098131; Sun, 14 Oct 2007 15:34:21 -0500 (CDT) (envelope-from dan) Date: Sun, 14 Oct 2007 15:34:20 -0500 From: Dan Nelson To: Artem Kuchin Message-ID: <20071014203420.GB2490@dan.emsphone.com> References: <008801c80e66$7be49490$0c00a8c0@Artem> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008801c80e66$7be49490$0c00a8c0@Artem> X-OS: FreeBSD 7.0-PRERELEASE User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-stable@freebsd.org Subject: Re: Question about 'top' values on memory usage X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Oct 2007 20:34:23 -0000 In the last episode (Oct 14), Artem Kuchin said: > Maybe someone with deeper knowledge of the internals of FreeBSD can > clean up something for me (any for many others)^ > > Here are lines from my top: > > PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND > 9258 hordelo_ru 1 4 0 40992K 4260K accept 0 0:00 0.00% httpd > 9257 hordelo_ru 1 44 0 40992K 4296K select 1 0:00 0.00% httpd > 9259 hordelo_ru 1 4 0 40992K 4292K select 1 0:00 0.00% httpd > > As you see, 'size' is the same for all processes, while RES varies. > > As i understand, the real memory taken by a process is RES and SIZE > include a bunch of shares .so libs, so, if more httpd's started each > will take only about 4300K more, so, 100 https will take 430000K to > run, right? The memory used by a process is SIZE. RES is the amount of that memory that's in memory. The rest would either be still on disk (in the form of executable or mmaped pages that haven't been accessed), in swap, or prezeroed pages that haven't been accessed yet (large blocks of malloc()'ed memory for example). Processes forked from the same parent can share the same pages until one process writes to one (a copy is then made so the other processes still see the right data). Chances are that those three httpd processes are sharing 99% of their pages. I don't know of any easy way of determing exactly how much non-shared memory a particular process has. -- Dan Nelson dnelson@allantgroup.com