On Tue, Aug 14, 2007 at 03:31:04PM +0100, Pete French
wrote:> If I have an executable which is staticly linked with many copies
> of it running (a CGI script in fact), will all those copies share
> the text segment of the executable on the disc, or will it actually
> use up real memory resource with many copies of the executable ? I
> have been assuming the former, but possibly that is not correct.
How I understand it:
A statically-linked binary contains portions/copies of the text, data,
and bss segments of .a library. These are part of the actual binary
itself, thus become part of the memory space of the program when run.
Only the text segment gets shared; the data and bss segments, as far as
I know, do not get shared.
With a statically-linked binary, when the binary forks, the text segment
is kept intact between the parent and child -- that is, there is only 1
in-memory copy of that segment.
However, *different parents* will have their own copy of that library in
their memory space.
This reminds me: it sure would be useful if we had something like
Solaris's pmap(1) on FreeBSD.
--
| Jeremy Chadwick jdc at parodius.com |
| Parodius Networking http://www.parodius.com/ |
| UNIX Systems Administrator Mountain View, CA, USA |
| Making life hard for others since 1977. PGP: 4BD6C0CB |