From owner-freebsd-questions Sun Jan 21 15:23:11 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailhost01.reflexnet.net (mailhost01.reflexnet.net [64.6.192.82]) by hub.freebsd.org (Postfix) with ESMTP id 767BA37B401 for ; Sun, 21 Jan 2001 15:22:53 -0800 (PST) Received: from rfx-216-196-73-168.users.reflexcom.com ([216.196.73.168]) by mailhost01.reflexnet.net with Microsoft SMTPSVC(5.5.1877.197.19); Sun, 21 Jan 2001 15:21:04 -0800 Received: (from cjc@localhost) by rfx-216-196-73-168.users.reflexcom.com (8.11.1/8.11.0) id f0LNMkM31601; Sun, 21 Jan 2001 15:22:46 -0800 (PST) (envelope-from cjc) Date: Sun, 21 Jan 2001 15:22:46 -0800 From: "Crist J. Clark" To: Cliff Sarginson Cc: Mike Meyer , Gustavo Vieira Goncalves Coelho Rios , questions@FreeBSD.ORG Subject: Re: small program eats lot of memory Message-ID: <20010121152246.X10761@rfx-216-196-73-168.users.reflex> Reply-To: cjclark@alum.mit.edu References: <14955.1209.195848.394006@guru.mired.org> <01012121054701.03293@buffy> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <01012121054701.03293@buffy>; from cliff@raggedclown.net on Sun, Jan 21, 2001 at 09:05:47PM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Jan 21, 2001 at 09:05:47PM +0100, Cliff Sarginson wrote: > On Sunday 21 January 2001 16:48, Mike Meyer wrote: > > Gustavo Vieira Goncalves Coelho Rios types: > > > I compiled and executed a small program and it's eating about 336 > > > of real memory (rss) and 840 of virtual size memory (vsz), may some > > > one explain why a simple program eats about 1 MB of memory? > > > > You linked it shared, right? That 1MB includes all of every shared > > library it uses, whether it uses those functions or not. > > Pardon ! It certainly does not ! That is the point of shared libraries - > the code is *shared* between processes using it. The required code is > then made dynamically available. The purpose of shared libraries is to share _disk_ space, not memory space. It's an easy enough test. Take the original little program, $ cat > sizetest.c < #include int main() { sleep(300); return 0; } EOF $ cc -o sizetest sizetest.c $ cc -static -o sizetest_s sizetest.c $ ls -l sizetest{,_s} -rwxr-xr-x 1 cjc wheel 4380 Jan 21 15:17 sizetest -rwxr-xr-x 1 cjc wheel 6947 Jan 21 15:17 sizetest_s $ ./sizetest & ./sizetest_s & sleep 10 ; ps aux | grep sizetest cjc 31567 0.0 0.2 840 272 p2 S 3:17PM 0:00.00 ./sizetest cjc 31568 0.0 0.0 136 20 p2 S 3:17PM 0:00.00 ./sizetest_s The static one takes up less memory according to ps(1), but more disk. -- Crist J. Clark cjclark@alum.mit.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message