Important: The information in this document is obsolete and should not be used for new development.
Loading Code Segments
The Segment Manager loads a code segment into memory automatically when you call any externally referenced routine in that segment. In most cases, the Segment Manager moves the block occupied by the code segment as high in the application heap as possible (by calling the Memory Manager procedureMoveHHi) and locks the block (by callingHLock) so that it cannot be moved or purged. You can disable or enable the call toMoveHHiand monitor the loading of segments into memory by manipulating two low-memory global variables.If a code segment to be loaded is unlocked (that is, if it's not in memory and its
resLockedattribute is clear, or if it is in memory and is unlocked), then the_LoadSegtrap calls the Memory Manager procedureMoveHHito move the segment toward the top of the current heap. To prevent heap fragmentation, you should call the Memory Manager procedureMaxApplZoneearly in your application's execution. Otherwise, the heap will grow incrementally, and these automatic calls toMoveHHimay leave your code segments scattered throughout the heap. You can, however, disable the call toMoveHHiby setting the low-memory global variableSegHiEnableto 0. If this variable contains the value 0,_LoadSegdoes not callMoveHHito move the segment toward the top of the heap.Occasionally, especially during application development, it is useful to monitor the otherwise largely invisible process of loading segments. You can do this by manipulating the system global variable
LoadTrap. Before any routine in a newly loaded code segment is executed, the_LoadSegtrap inspects theLoadTrapglobal variable. IfLoadTraphas a nonzero value, then_LoadSegcalls the_Debuggertrap. This provides a useful way for you to monitor the loading of segments by the Segment Manager.