2.3.4 Heap Encoding
HeapItems in the Heap typically occur in any order as long as the Heap references to them (that is, any rules that reduce to HeapRef) are correct. For example, PropertyInfo blocks occur in an order that is different from the lexical order of the properties, and Encoded-String occurs at any location. When updates are being implemented, this implementation of the Heap is intended to allow for best-fit algorithms.
Strings that fit into the original Encoded-String, even if they are shorter than the original strings, SHOULD be written into the old location. However, it is not an error if each new string update is written into a new location in the Heap.
Because the Heap is loosely organized, garbage space is inevitably created and the Heap becomes fragmented. There are sequences of octets within the Heap that have no corresponding references to them by any HeapRef, and there might be large sequences of NULL octets near the end of the Heap. This situation is permitted to enable garbage collection algorithms and easy reuse of large blocks without having to perform heap compaction and HeapRef updates for all heap items after each operation. Encoders with such garbage collectors MAY transmit encoded objects without previously performing garbage collection. Decoder implementations MUST be prepared to deal with the presence of Heaps that have not been garbage collected.
The Heap process is important in decoding because code that processes the Heap and HeapItems MUST NOT fault if it encounters blocks that have no reference to them or encounters garbage octets at the end of the Heap.
The client MUST NOT alter a CIM class definition, including its Heap, after instances for it have been created and are in use. A client MAY only alter a ClassHeap or a MethodHeap when creating or updating a CIM class definition for which no instances currently exist. This is because copied images of the ClassPart are made for CIM instances as part of their encoding. CIM objects that have this image altered MUST be rejected by the server.