As an example, suppose two separate programs, prog1
and prog2, use
shared libc routines
heavily. Suppose that the a.out
portion of prog1
is 256Kb in size, while the prog2
a.out portion
is 128Kb. Assume also that the shared libc
is 512Kb in size. Figure 5-2 “Two Processes
Sharing libc ”
shows how physical memory might look when both processes run simultaneously.
Notice that one copy of libc
is shared by both processes. The total memory requirement for these
two processes running simultaneously is 896Kb (256Kb + 128Kb + 512Kb).
Compare this with the memory requirements if prog1
and prog2 had
been linked with the archive version of libc.
As shown in Figure 5-3 “Two Processes
with Their Own Copies of libc ”,
1428Kb of memory are required (768Kb + 640Kb). The numbers in this
example are made up, but it is true in general that shared libraries
reduce memory requirements.