TAL Programmer's Guide

CRE Guidelines for TAL
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–41
The User Heap The user heap is a shared resource the CRE makes available to your routines,
regardless of language. The user heap is in the block named #HEAP, which differs
from the CRE-reserved block named #CRE_HEAP.
Binder allocates memory space for the user heap as follows:
If a TAL program contains a small-memory model C or Pascal module, the user
heap is the last global data block in the lower 32K-word area of the user data
segment. (The last data block is located just below the user data stack.)
If a TAL program contains a large-memory-model C or Pascal module or contains
no C or Pascal routines, the user heap is the last data block in the automatic
extended data segment.
If the TAL program also uses explicit extended data segments, follow the
instructions given in “Explicit Extended Data Segments” earlier in this section.
Setting the User Heap Size
To set the size of the user heap, specify the HEAP directive in the TAL compilation
command or anywhere in the TAL module that contains the MAIN routine. The size
specified in the last HEAP directive encountered in the TAL compilation takes effect.
The ENV COMMON directive must also be in effect. If a TAL program invokes a
routine that needs the user heap, the HEAP directive is required. The following TAL
directive line sets a user heap of 5 memory pages:
?HEAP 5
The heap size is the number of 2048-byte memory pages. Specify an unsigned decimal
constant in one of the following ranges:
Memory
Model Range Notes
Small 0 through 31 The heap size you can specify depends on your use of the lower
32K-word area of the user data segment.
Large 0 through 32,767 When a program runs, the CRE increases the heap size as needed
up to the maximum size of the automatic extended segment. Do
not set an arbitrarily large size because an equal amount of disk
space (for swapping) must be available.
Accessing the User Heap
Only C and Pascal routines can allocate and return user heap space. To allocate and
return user heap space, C and Pascal routines call the following library routines:
Request C Library Routine Pascal Library Routine
Obtain heap space malloc NEW
Return heap space free DISPOSE