CRE Programmer's Guide

CRE Services
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
2-40
TNS CRE Memory
heap space. TAL routines cannot access the TNS CRE functions that allocate heap
space. Data allocated on the heap by a routine written in one language can be
accessed by a routine written in another language by passing the address of the data
from one routine to another. Routines that access the same data on the heap must
specify the same data layout, even if you must use language-specific syntax in each
language to describe the same data.
The heap is maintained in a data block called #HEAP. The TNS CRE allocates space
for #HEAP in the user data segment (just below your program’s run-time stack) if your
program uses a small-memory model, or in extended memory (after all other data
blocks) if your program uses a large-memory model or a wide-memory model.
Specifying the Size of the Heap
You can specify the size of the heap using:
The TNS CRE uses the heap size you specify as the initial size of the heap.
If a program uses a small-memory model, the heap is allocated in the user data
segment, just below the data stack. The TNS CRE uses the size you specify as the
initial size of the heap, but the TNS CRE does not increase the size of the heap once
your program begins running.
If a program uses a large-memory model or a wide-memory model, the heap is the last
block in the extended memory segment. The TNS CRE increases the size of the heap,
if needed, up to the maximum size of an extended memory segment, 127.5 MB. Your
program requires disk space to accommodate the extended memory segment.
Therefore, set the initial size of the heap to be only as large as your program requires.
Use the heap statistics feature to help you determine the size of the heap.
Requesting Space on the Heap:
Only C routines can request space on the heap. Neither COBOL nor FORTRAN
supports pointers and, therefore, cannot request or access heap data. TAL
supports pointers but cannot call the TNS CRE to request heap space. A TAL
routine can, however, call a C routine to obtain heap space, after which the TAL
routine can access heap data using the pointer returned to it by the C routine.
C routines request heap space by calling the C malloc() library function, and
return heap space by calling the C
free() library function.
Construct Product Reference
HEAP pragma C C/C++ Programmer’s Guide
HEAP compiler directive TAL TAL Reference Manual
SET HEAP command Binder Binder Manual
Note. The TNS CRE does not support the HEAP PARAM. In the Guardian environment, you
can use compiler directives or Binder commands to achieve the same effect as the HEAP
PARAM.