Shared Libraries

When you use static libraries, the code is linked physically into your executable program. If you have a big library, say 10 megabytes, which is linked into a dozen programs, you will have 120 megabytes of disk space consumed. With today’s huge hard drives, that’s not too big of a deal, but you also have the libraries taking up those megabytes of space in each program’s memory. This is a much bigger problem. Memory is a scarce shared resource, so having duplicate copies of library code each occupying its own pages in memory can put stress on the memory system and cause paging.

Shared libraries were created to address this problem. Instead of copying the code into the programs, just a reference is included. When the program needs ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.