2.2.66 Heap

A Heap consists of a length and a linear series of HeapItem entries. A Heap is loosely defined and consists of the HeapItem blocks in any order. However, there are three separate Heaps that MUST be maintained distinctly: ClassHeap (only applies to CIM class data), InstanceHeap (only applies to CIM instance data), and MethodHeap (only appears within ClassType blocks and only contains information relating to the methods for a CIM class). These Heaps MUST be separate, and they only apply within their respective encoding blocks. That is, ClassHeap only occurs within ClassType, InstanceHeap only occurs within InstanceType, and MethodHeap only occurs within MethodsPart. This is because ClassHeap (references) to HeapItem entries are encoded as simple integer offsets from the beginning of the relevant Heap, so the actual target Heap is implied by the block in which the HeapRef occurs.

 Heap = HeapLength *HeapItem
 HeapLength = UINT32    ; 31 bits with MS bit set

HeapLength is a 32-bit value with the most significant bit always set (using little-endian binary encoding for the 32-bit value), so that the length is actually only 31 bits.

The items appear in any order and do not need to be packed. Heaps MAY contain unused octets between HeapItems. As long as any HeapRef type is properly adjusted to point to items within the Heap, such gaps are acceptable and are permitted to accommodate garbage collection mechanisms in the encoders and decoders.

Any HeapRef value MUST be the offset (in total octets) of the corresponding HeapItem, and any HeapItem MUST have exactly one HeapRef in some other data structure that points to it.

HeapItem entries MUST NOT be shared. That is, there MUST NOT exist two HeapRef values that point to the same HeapItem.