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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.