THREADHEAP

Derivation: THREAD level HEAP storage

THREADHEAP controls the allocation and management of thread-level heap storage. Separate heap segments are allocated and freed for each thread based on the THREADHEAP specification.

For PL/I MTF applications, controlled and based variables declared in a subtask are allocated from heap storage specified by THREADHEAP. Variables in the main task are allocated from heap storage specified by HEAP.

Library use of heap storage in a substack is allocated from the enclave-level heap storage specified by the ANYHEAP and BELOWHEAP options.

The default value for non-CICS applications is THREADHEAP(4K,4K,ANY,KEEP).

THREADHEAP is ignored under CICS®.

Read syntax diagramSkip visual syntax diagram
Syntax

>>-THREADHeap--(--+-----------+--,--+-----------+--,------------>
                  '-init_size-'     '-incr_size-'      

   .-ANYWHERE-.     .-KEEP-.      
>--+----------+--,--+------+--)--------------------------------><
   +-ANY------+     '-FREE-'      
   '-BELOW----'                   

init_size
The minimum initial size of thread heap storage, and is specified in n, nK, or nM. Storage is acquired in multiples of 8 bytes. A value of zero (0) causes an allocation of 4K.
incr_size
The minimum size of any subsequent increment to the noninitial heap storage is specified in n, nK, or nM. The actual amount of allocated storage is the larger of two values, incr_size or the requested size, rounded up to the nearest multiple of 8 bytes. If you specify incr_size as 0, only the amount of the storage needed at the time of the request (rounded up to the nearest 8 bytes) is obtained.
ANYWHERE|ANY
Specifies that the heap storage can be allocated anywhere in storage. If there is no available storage above the line, storage is acquired below the 16-MB line. The only valid abbreviation of ANYWHERE is ANY.
BELOW
Specifies that the heap storage must be allocated below the 16M line.
KEEP
Specifies that storage allocated to THREADHEAP increments is not released when the last of the storage in the thread heap increment is freed.
FREE
Specifies that storage allocated to THREADHEAP increments is released when the last of the storage in the thread heap increment is freed.

CICS consideration

Even though this option is ignored under CICS, the default increment size under CICS has changed from 4K (4096 bytes) to 4080 bytes, to accommodate the 16 bytes CICS storage check zone.

Usage notes

  • If the requesting routine is running in 24-bit addressing mode and THREADHEAP(,,ANY,) is in effect, THREADHEAP storage is allocated below the 16M line based upon the HEAP(,,,,initsz24,incrsz24) settings.
  • PL/I MTF considerations—The thread-level heap is allocated only in applications that use the PL/I MTF. For PL/I MTF applications, controlled and based variables specified in subtasks are located in the thread-level heap.
    If the main program is running in 24-bit addressing mode and THREADHEAP(,,ANY,) is in effect, heap storage is allocated below the 16M line. The only case in which storage is allocated above the line is when all of the following conditions exist:
    • The user routine requesting the storage is running in 31-bit addressing mode.
    • HEAP(,,ANY,,,) is in effect.
    • The main routine is running in 31-bit addressing mode.
  • When running PL/I with POSIX(ON) in effect, THREADHEAP is used for allocating heap storage for PL/I base variables declared in non-IPTs. Storage allocated to all THREADHEAP segments is freed when the thread terminates.
  • THREADHEAP(4K,4K,ANYWHERE,KEEP) provides behavior compatible with the PL/I TASKHEAP option.
  • The initial thread heap segment is never released until the thread terminates.
  • THREADHEAP has no effect on C/C++ or Fortran for z/OS MTF applications.