Shared libraries
Jeff d'Arcy
jdarcy at seqp4.ORG
Wed Apr 24 04:30:14 AEST 1991
mohta at necom830.cc.titech.ac.jp (Masataka Ohta) writes:
>As shown <112 at titccy.cc.titech.ac.jp> in comp.unix.wizards, total size of
>binaries excluding X11 is comparable to its machines real memory size.
Yippee. As you should know, the size *on disk* does not represent the size
*in memory*. Consider the following C program:
#define SIZE 4096
char fubar[SIZE][SIZE];
int main()
{
int i;
for (;;) {
for (i = 0; i < SIZE; ++i)
fubar[i][0] = 0;
}
}
On the machine I'm using, this creates an a.out file 32116 bytes long. Do you
think that's all the space it will take up while running? If so, then I need
not argue any further since you're obviously deranged. It is irrelevant that
most of the space used by this program is for data. In real systems, this is
the case for many programs, and total virtual space will typically be quite a
bit greater than physical memory. What matters most is how much memory you
can use for paging the infrequently referenced data. Pages that are used often
will not get paged out, and can pretty much be considered fixed memory. This
category includes much of the text in many programs, in particular large parts
of libc.
If you don't use shared libraries, those portions of libc will be resident
all over the place, as parts of the text of many *different* programs (yes,
text for the *same* program is shared anyway). With shared libraries, they
are resident in only one place, saving a significant fraction of physical
memory. Increasing the amount of physical memory available for paging by as
little as a few percent can cause a *significant* improvement in overall
system performance. Do you really think so many skilled and knowledgeable
OS developers would implement shared libraries if they weren't worth it?
My apologies to the majority of the readership, who already know all this.
More information about the Comp.unix.internals
mailing list