C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

Usage Guidelines
If the RUNNABLE pragma is not specified, the HEAP pragma does not affect the compilation.
One page equals 2048 bytes (2 kilobytes).
If you do not use the HEAP pragma when compiling a TNS program with the RUNNABLE
pragma, the compiler automatically provides a heap of one page.
For native C/C++, the HEAP pragma must be entered on the compiler RUN command line;
for TNS C and c89 in the OSS environment, the pragma can be entered either on the compiler
RUN command line or in the source text.
Native C and C++ programs use a different heap architecture than TNS programs. Because
of this, native C and C++ programs normally do not need to specify maximum heap size; the
default value for the heap_max attribute of a program file is zero, indicating that the size of
the heap is limited only by available resources.
For native C and C++ programs, you should not specify the HEAP pragma unless there is an
unusual reason to limit the heap size to less than the capacity of the program address space.
The HEAP pragma specifies an upper bound on heap size by setting the heap_max attribute
in a new loadfile; for example, specifying HEAP n BYTES is equivalent to specifying -set
heap_max n to the eld linker for the loadfile.
You do not need to recompile to change the setting. The HEAP pragma setting and -set
heap_max setting can be replaced later by using the linker command -change heap_max
n filename, where filename designates the program file.
See the appropriate linker manual for information on setting the heap_max flag with the
appropriate number of bytes.
If you do not use the HEAP pragma when compiling a native program with the RUNNABLE
pragma, the compiler leaves the maximum heap size unspecified. This causes the value used
to be determined by the first of these that has a nonzero value:
1. The pe_heap_max value assigned to the program file by a process that launches it
2. The heap_max attribute of the program file
If the heap_max attribute remains zero, all the user data area (minus that area used for global
data segments and the argv[] and envp[] arrays) is available for the heap.
If you do use the HEAP pragma when compiling a native program, the space specified must
be sufficient to contain at least the global data segments and the argv[] and envp[] arrays.
The maximum size of native user heap can be affected by the use of operating system memory
segments:
Flat segments are allocated in the same area, downward from its upper bound.
Certain products allocate segments in the same area, causing address collisions when
certain features are used; the QIO Configuration and Management Manual provides
guidance on one such instance.
DLL text and data segments can be loaded into the same area.
When such segments already exist, the heap area is bounded by the start of the segment
with the lowest address. An attempt to allocate a flat segment or load a DLL can fail if
the heap has already consumed the area needed.
Heap growth, like the allocation or growth of other data segments, will fail if insufficient swap
space is available for the processor.
If your program causes a run-time error message that it is out of virtual memory, try increasing
the swap file space available to it, following the guidelines in the Kernel-Managed Swap
Facility (KMSF) Manual.
200 Compiler Pragmas