Language Environment (LE) is a component of the z/OS environment that provides a common running environment for IBM versions of some advanced languages (such as c,c++, Cobol,fortan, and pl/i). Heap Storage is a concept that le is used for storage management (Storage Management). The heap storage typically contains dynamically allocated storage space during the program's operation. This article mainly introduces the basic structure of heap storage, and shows how the content in heap storage changes with the application and release operation, and helps users to understand heap storage more deeply by a simple example.
First we introduce a few terms related to heap.
Heap:heap is a storage area used by the Le program. Heap usually contains an initial heap segment (fragment) and 0 or more increments (incremental)
Heap segment:le contiguous storage area obtained from the operating system
HEAP element: Invokes the CEEGTST allocated contiguous storage area through the Le API. Heap element is always allocated in a Heap segment
Heap Incremental: When the initial Heap segment was unable to meet the request for Heap storage, le added Heap from the operating system
(In order to reduce the ambiguity of translation, use English terms such as element,segment as much as possible below)
Next we introduce the layout of the heap storage in 31-bit mode:
The beginning of each heap segment is a heap header with a length of 32 bytes (8 whole words). The HEAP header contains the following 8 fields, each with a length of 4 bytes:
1. A four-character eyecatcher with "Hanc" to mark the beginning of a heap segment
2. Pointer to the next HEAP segment or HPCB (HEAP control block)
3. Pointer to previous heap segment or HPCB
4. Heapid
5. Pointer to this segment starting address (that is, segment addresses)
6. Start address of the largest idle element in segment (also known as root address)
7. Length of Heap segment (that is, segment)
8. Length of the largest idle element in the segment (also known as the root element length)
After the header is heap, it contains the heap element that has been allocated or is idle.
For an already allocated element, the first 8-byte header is divided into two parts: the first four bytes are the starting address of the segment where the element is located ; The next four bytes indicate the length of the element (including the length of the 8-byte header), followed by the user data area.
A Cartesian tree (flute Karlshu) is composed of all the idle elements in a segment. For the idle element, in the beginning part, the same 16-byte header is divided into 4 fields of 4 bytes in length, representing the address of the left node, the address of the right node, the size of the left node, and the size of the right node (we are not describing the concept of the Karshu about the Cartesian node). Each node represents an idle element.
Once we get a segment start address, we can navigate to all the idle elements within this segment through the header root and each free segment header.
Figure 1 is a simple schematic. This diagram depicts a heap segment, which contains the heap Header, two assigned and two idle element. The green arrows and Red arrows in the figure represent pointers to the segment start address and pointers to the idle segment start address, respectively.
Figure 1