From owner-freebsd-questions Sun Jan 21 21:19:35 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-10.mail.nl.demon.net [194.159.73.20]) by hub.freebsd.org (Postfix) with ESMTP id 490F437B6AF for ; Sun, 21 Jan 2001 21:18:59 -0800 (PST) Received: from [212.238.77.116] (helo=gateway.raggedclown.net) by post.mail.nl.demon.net with smtp (Exim 3.14 #2) id 14KZNY-0002bI-00; Mon, 22 Jan 2001 05:18:57 +0000 Received: from buffy.raggedclown.net (btvs.demon.nl [192.168.1.2]) by gateway.raggedclown.net (Postfix) with ESMTP id A72195DB3; Mon, 22 Jan 2001 06:17:39 +0100 (CET) Received: by buffy.raggedclown.net (Postfix on SuSE Linux 7.0 (i386), from userid 500) id 4A50912C4F; Mon, 22 Jan 2001 05:49:15 +0100 (CET) Date: Mon, 22 Jan 2001 05:49:15 +0100 From: Cliff Sarginson To: cjclark@alum.mit.edu Cc: Mike Meyer , Gustavo Vieira Goncalves Coelho Rios , questions@FreeBSD.ORG Subject: Re: small program eats lot of memory Message-ID: <20010122054915.D1639@raggedclown.net> References: <14955.1209.195848.394006@guru.mired.org> <01012121054701.03293@buffy> <20010121152246.X10761@rfx-216-196-73-168.users.reflex> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010121152246.X10761@rfx-216-196-73-168.users.reflex>; from cjclark@reflexnet.net on Sun, Jan 21, 2001 at 03:22:46PM -0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Jan 21, 2001 at 03:22:46PM -0800, Crist J. Clark wrote: > 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. > Well, this is news to me. > It's an easy enough test. Take the original little program, > > $ cat > sizetest.c < #include > #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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message