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: Processes
Chapter 7 - Segment Manager / Using the Segment Manager

Unloading Code Segments

You can use the UnloadSeg procedure to unload segments. To unload a particular segment, pass UnloadSeg the address of any externally referenced routine contained in that segment. For example, to unload the segment that contains the procedure DoPrintFile, execute this line of code:

You can call UnloadSeg at any time except when you are executing code contained in the segment to be unloaded. A typical strategy is to unload all code segments except segment 1 and any other essential code segments each time through your application's main event loop.

Before you unload a segment, make sure that your application no longer needs it. Never unload a segment that contains a completion routine or other interrupt task (such as a Time Manager task or VBL task) that might be executed after the segment is unloaded. Never unload a segment that contains routines in the current call chain. ·
The UnloadSeg procedure does not actually remove the segment from memory. Instead, it unlocks the segment, thereby making the segment relocatable and purgeable. This permits the Memory Manager to relocate or purge the segment if necessary to gain some space in the application heap.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996