Date: Sun, 21 Jan 2001 15:22:46 -0800 From: "Crist J. Clark" <cjclark@reflexnet.net> To: Cliff Sarginson <cliff@raggedclown.net> Cc: Mike Meyer <mwm@mired.org>, Gustavo Vieira Goncalves Coelho Rios <gustavo@ifour.com.br>, questions@FreeBSD.ORG Subject: Re: small program eats lot of memory Message-ID: <20010121152246.X10761@rfx-216-196-73-168.users.reflex> In-Reply-To: <01012121054701.03293@buffy>; from cliff@raggedclown.net on Sun, Jan 21, 2001 at 09:05:47PM %2B0100 References: <14955.1209.195848.394006@guru.mired.org> <01012121054701.03293@buffy>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <gustavo@ifour.com.br> 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 <<EOF #include <stdio.h> #include <stdlib.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010121152246.X10761>