Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 May 2000 09:43:07 +0100 (BST)
From:      Jan Grant <Jan.Grant@bristol.ac.uk>
To:        Gustavo Vieira Goncalves Coelho Rios <kernel@tdnet.com.br>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: what's the advantage...
Message-ID:  <Pine.GHP.4.21.0005170935130.487-100000@mail.ilrt.bris.ac.uk>
In-Reply-To: <39214A8F.FC9C023E@tdnet.com.br>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 16 May 2000, Gustavo Vieira Goncalves Coelho Rios wrote:

> > On Tue, 16 May 2000, Gustavo Vieira Goncalves Coelho Rios wrote:
> > 
> > > I got surprised when i compiled two versions of the same program, and
> > > the one statically (-static flag) linked use less memory than that
> > > dynamically linked.
> 
> Programs linked with the -static flag use less memory than that ones not
> linked with -static flag.
> Why ?
> 
> > > How can one program that were static linked uses less memory that the
> > > same one done using the default linking?
> > 
> > I'd suspect that any (small) differences you're seeing could be
> > attributed to mmapped .so files needing to be aligned with page
> > boundaries.
> 
> How could i do that ?
> 
> So, try this simple program and use ps or top to see the difference
> between them both.

I tried it, and I see what you mean. If you get lsof to look at the
processes, however, you'll see where the difference lies.

With a statically-linked program, only the library functions it needs
(those it uses and their dependencies) are linked in; the size of the
executable is pretty much the total text usage of the program.

With a dynamically-linked program, the libc.so is mmapped in en
bloc; there's no way of avoiding this, and it counts towards the total
size of the program.

However, in theory the text of .so libraries can be shared
between processes, thus cutting down on the total average
overhead. I've no idea if FreeBSD implements that sharing - anyone care
to comment?

-- 
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44(0)117 9287163 Fax +44 (0)117 9287112 RFC822 jan.grant@bris.ac.uk
Axioms speak louder than words.



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?Pine.GHP.4.21.0005170935130.487-100000>