When an application creates keyed DataWriters and DataReaders (these are DataWriters and DataReaders whose Topics are keyed), Connext DDS needs to allocate memory for instance metadata. (Such metadata is not required for non-keyed data.) This includes memory for instance-specific metadata such as maintaining the current state of each instance and memory for instance keyhashes. Keyhashes are 16-byte representations of unique instances that are sent along with a sample. They allow DataWriters and DataReaders to quickly identify each unique instance without comparing all individual key fields.
The memory used for instances is separate from sample memory. A DataWriter or DataReader may have metadata stored for an instance even if there are currently no samples in the DataWriter's or DataReader's queue. Furthermore, memory related to instances and instance metadata is not deleted, but reclaimed. How memory is reclaimed for instances depends on how your QoS is set, and those QoS settings differ between DataWriters and DataReaders. For example, disposing an instance does not necessarily free up memory, depending on how your QoS is configured. (By default, the QoS settings do not free instance memory when instances are disposed.)
Figure 6.5: Comparing Sample Memory and Instance Memory
Consider a reliable, volatile DataWriter that writes a sample of an instance for the first time. The DataWriter stores the sample in its queue. At the same time, the DataWriter stores the keyhash for that instance, the state of the instance (ALIVE), and additional metadata about the instance. All matching DataReaders acknowledge the sample, so the DataWriter removes the sample from its queue, allowing that memory to be reused by another sample; however, the instance metadata is still valid, and continues to be stored.
Similarly, when each DataReader receives the first update about an instance, it stores the sample in its queue; it also stores the instance’s keyhash and state (ALIVE), and additional metadata about the instance. When the DataReader takes the sample from the queue, the sample is removed from the queue, allowing that memory to be reused by another sample; however, the instance metadata is still valid and continues to be stored.
Details on how DataWriters and DataReaders allocate and reclaim memory for instances can be found in the following sections:
© 2020 RTI