Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /
Chapter 1 - CFM-Based Runtime Architecture / Closures


Reference Counts

The Code Fragment Manager keeps a reference count for every connection currently in a process. This value indicates the number of closures that reference the connection. For example, in Figure 1-2, the shared fragments dogLib and cowLib each have a reference count of 2. If the plug-in is released, the reference count for each would be decremented. When the reference count of a connection drops to zero, the connection is not part of any closure and the Code Fragment Manager is free to release it if necessary.

The Code Fragment Manager also keeps similar count values for each section of a shared fragment that indicates the number of connections associated with it. For example, in Figure 1-4, the code section for dogLib has a reference count of 2, and the two data sections for dogLib each have a reference count of 1. If the process containing dogApp terminates, the reference count for the dogLib data section in that process drops to zero, so the Code Fragment Manager can release the section. The reference count for the code section only drops to 1, however, so it remains in memory.

Finally, the Code Fragment Manager also keeps track of the number of connections associated with a given fragment container. If a fragment container has no connections associated with it, the Code Fragment Manager can release the container from memory.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997