From owner-freebsd-stable@FreeBSD.ORG Tue Oct 16 09:04:10 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 ABE9816A421 for ; Tue, 16 Oct 2007 09:04:10 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82]) by mx1.freebsd.org (Postfix) with ESMTP id 2FB1A13C4C1 for ; Tue, 16 Oct 2007 09:04:09 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.14.1/8.14.1) with ESMTP id l9G947WJ002004; Tue, 16 Oct 2007 19:04:07 +1000 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.14.1/8.14.1/Submit) id l9G946pp002003; Tue, 16 Oct 2007 19:04:06 +1000 (EST) (envelope-from peter) Date: Tue, 16 Oct 2007 19:04:06 +1000 From: Peter Jeremy To: Artem Kuchin Message-ID: <20071016090406.GL1184@turion.vk2pj.dyndns.org> References: <008801c80e66$7be49490$0c00a8c0@Artem> <20071014203420.GB2490@dan.emsphone.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qjNfmADvan18RZcF" Content-Disposition: inline In-Reply-To: <20071014203420.GB2490@dan.emsphone.com> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc 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: Tue, 16 Oct 2007 09:04:10 -0000 --qjNfmADvan18RZcF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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)^ >=20 > Here are lines from my top: >=20 > 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 >=20 > As you see, 'size' is the same for all processes, while RES varies. >=20 > 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? Determining the amount of shared vs unshared memory for each process is not totally trivial. All I can suggest is using procfs and reading /proc/<>/map eg: turion% dd if=3D/proc/curproc/map bs=3D256k 0x400000 0x402000 2 0 0xffffff002e4710e0 r-x 1 0 0x0 COW NC vnode /bin/dd 0x502000 0x503000 1 0 0xffffff001c41cd20 rw- 2 0 0x2180 NCOW NNC default - 0x503000 0x505000 2 0 0xffffff001c41cd20 rwx 2 0 0x2180 NCOW NNC default - and so on The columns are: start address, end address, resident pages, private resident pages, vm_object_t address, protection, reference count, shadow count, flags, cow, copy-needed, type, path See for flags This will let you indentify shared vs private space as well as whether it's file or swap backed. --=20 Peter Jeremy --qjNfmADvan18RZcF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHFH6G/opHv/APuIcRAon1AJ4gceMqNrqaWi8o3BpoXaWB9pvAvgCfbe9b QnxXx1y2iNiT5UUudZBXsnc= =XXpU -----END PGP SIGNATURE----- --qjNfmADvan18RZcF--