Important: The information in this document is obsolete and should not be used for new development.
About the Segment Manager
Your application's executable code is stored in its resource fork as one or more resources of type'CODE'
. These code resources are known as segments because the division of routines into code resources is controlled by segmentation directives you provide to your development system.The Process Manager loads some code segments into memory when your application is launched. The Segment Manager loads other segments whenever you call any externally referenced routine contained in those segments. Both of these operations occur completely automatically and rely on information stored in your application's jump table and in the individual code segments themselves.
The Segment Manager loads segments into relocatable, purgeable blocks in your application heap. A segment is locked when it is first read into memory and at any time thereafter when routines in the segment are executing. This locking prevents the block from being moved during heap compaction and from being purged during heap purging.
Although needed code segments are loaded into memory automatically, it is your application's responsibility to unload any segments that are not currently being used. The Segment Manager provides a single procedure,
UnloadSeg
, that you can call to unload a segment. To unload a segment is simply to unlock it. By unlocking unneeded segments, you allow them to be relocated or purged if necessary to accommodate a later memory-allocation request. Thus, using the Segment Manager to unload unneeded segments is one important aspect of an efficient memory-management policy.The following sections describe in detail the reasons for segmenting an application and the structure of the jump table.
Subtopics
- Code Segmentation
- The Jump Table