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 toMoveHHi
and 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
resLocked
attribute is clear, or if it is in memory and is unlocked), then the_LoadSeg
trap calls the Memory Manager procedureMoveHHi
to move the segment toward the top of the current heap. To prevent heap fragmentation, you should call the Memory Manager procedureMaxApplZone
early in your application's execution. Otherwise, the heap will grow incrementally, and these automatic calls toMoveHHi
may leave your code segments scattered throughout the heap. You can, however, disable the call toMoveHHi
by setting the low-memory global variableSegHiEnable
to 0. If this variable contains the value 0,_LoadSeg
does not callMoveHHi
to 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_LoadSeg
trap inspects theLoadTrap
global variable. IfLoadTrap
has a nonzero value, then_LoadSeg
calls the_Debugger
trap. This provides a useful way for you to monitor the loading of segments by the Segment Manager.