Associated with Memory streams are objects that are instantiated from a subclass of TChunkyMemory. This relationship is shown in the class hierarchy in
Figure 45.
TChunkyMemory is an abstract class defining protocol inherited by concrete classes intended to manage virtual memory. Note that TChunkyStream references an instance of TChunkyMemory through a pointer even though TChunkyMemory is an abstract class that should not be instantiated directly. Through this pointer reference, TChunkyStreams can invoke virtual methods in concrete subclasses of TChunkyMemory. The protocol for these memory objects is shown in Figure 18
.
You don't need to worry about the protocol for TChunkyMemory or its descendants, except to create instances of these descendants (such as THeapChunkyMemory) which you will pass as arguments to constructors for memory streams. Sample code that does this can be found under "Using streams." TChunkyMemory is an abstract base class that manages memory in chunks of a specified size.
Memory is allocated in chunks (specified by SetChunkSize), but the user still views the memory as a series of bytes. THeapChunkyMemory is a concrete class that manages chunky memory that has been allocated on a heap. The heap might be allocated from system resources by default, or from a client-specified heap as an alternative. The allocation of heap memory is really the only issue that clients of memory streams need to be concerned with. The rest of the protocol for dealing with subclasses of TChunkyMemory is handled automatically by the streams themselves.