Important: The information in this document is obsolete and should not be used for new development.
Loading Code SegmentsThe 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 procedure
MoveHHi) and locks the block (by calling
HLock) so that it cannot be moved or purged. You can disable or enable the call to
MoveHHiand 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 procedure
MoveHHito move the segment toward the top of the current heap. To prevent heap fragmentation, you should call the Memory Manager procedure
MaxApplZoneearly in your application's execution. Otherwise, the heap will grow incrementally, and these automatic calls to
MoveHHimay leave your code segments scattered throughout the heap. You can, however, disable the call to
MoveHHiby setting the low-memory global variable
SegHiEnableto 0. If this variable contains the value 0,
_LoadSegdoes not call
MoveHHito 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 the
LoadTrapglobal variable. If
LoadTraphas a nonzero value, then
_Debuggertrap. This provides a useful way for you to monitor the loading of segments by the Segment Manager.