If you are forced to call MoreMasters so many times that it causes a significant slowdown, you could change the moreMast field of the zone header to the total number of master pointers you need and then call MoreMasters just once. Afterward, be sure to restore the moreMast field to its original value. Because MoreMasters allocates memory, you should not call it at interrupt time. The calls to MoreMasters at the beginning of your application should be in the main code segment of your application or in a segment that the main segment never unloads. The Memory Manager expands the application heap only up to the byte preceding this limit.
Nothing prevents the stack from growing below the application limit.
If the Operating System detects that the stack has crashed into the heap, it generates a system error. To avoid this, use GetApplLimit and the SetApplLimit procedure to set the application limit low enough so that a growing stack does not encounter the heap. The GetApplLimit function does not indicate the amount of memory available to your application. The global variable ApplLimit contains the current application heap limit. SetApplLimit Use the SetApplLimit procedure to set the application heap limit, beyond which the application heap cannot expand.