Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Linker and Libraries User's Guide: HP 9000 Computers > Chapter 5 Creating and Using Libraries

Example Program Comparing Shared and Archive Libraries

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

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).

Figure 5-2 Two Processes Sharing libc

Two Processes Sharing libc

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.

Figure 5-3 Two Processes with Their Own Copies of libc

Two Processes with Their Own Copies of libc
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.