22.2.1 Memory Management for DataReaders Using Generated Type-Plugins

Figure 22.3: Adding DDS Samples to DataReader’s Queue shows how DDS samples are processed and added to the DataReader’s queue.

Figure 22.3: Adding DDS Samples to DataReader’s Queue

The RTPS DATA DDS samples received by a DataReader can be either batch DDS samples or individual DDS samples. The DataReader queue does not store batches. Therefore, each one of the DDS samples within a batch will be deserialized and processed individually.

When the DataReader processes a new sample, it will deserialize it into a sample obtained from a pre-allocated pool. By default, to provide predictability and determinism, the sample obtained from the pool is allocated to its maximum size. For example, with the following IDL type, each sample in the DataReader queue will consume 1 MB, even if the actual size is smaller.

struct VideoFrame {  
	boolean keyFrame; 
	sequence<octet,1024000> data;
};

In the above example, it is possible to reduce the memory consumption by declaring the data sequence as unbounded and by generating code for the type with the command-line option -unboundedSupport. In this case, the middleware will not preallocate 1 MB for the data member. Instead, the generated code will deserialize incoming samples by dynamically allocating and deallocating memory to accommodate the actual size of the data sequence.

© 2020 RTI