How do I minimize the memory footprint and avoid dynamic memory allocation?

Note: Applies to RTI Connext 4.x and above.

The first and foremost step to reducing the memory footprint is an architectural review. The number of topics, the queue sizes, whether or not you use keys, the number of domains, or the usage of partitions have a great impact on the memory footprint of your application. Most often, the biggest memory reductions can be achieved by examining your architecture. 

The next step is to fine tune the memory footprint using the Quality of Service (QoS) parameters. Not only can you control the amount of memory, but also whether memory allocation should only occur during initialization or whether it is allowed during run time.

The QoS parameters to look at include:

  • DDS_ResourceLimitsQoSPolicy (for DataReaders and DataWriters) controls the number of samples allocated. Tune both the initial and max values to optimize the memory footprint. By setting initial == max, you will avoid dynamic memory allocation. You will also need to set the incremental count = 0 in DDS_DomainParticipantQos.resource_limits.local_writer_allocation and local_reader_allocation.
  • DDS_DomainParticipantResourceLimitsQosPolicy, DDS_DataReaderResourceLimitsQosPolicy, and DDS_DataWriterResourceLimitsQosPolicy 
  • DDS_EventQosPolicy
  • BuiltinTopicReaderResourceLimits_t (used in DDS_DiscoveryConfigQosPolicy).

If you are using all of the following:

  • 4.2e or below
  • C or C++
  • very large keyed samples

you should hand-edit the <Foo>Plugin.h (where Foo is the data type) generated by rtiddsgen so that the key-holder data structures are smaller than the samples themselves (by default we use the same struct). See the comments in <Foo>Plugin.h for instructions.

If you are using 4.3e or above, you can use the attached NDDS_QOS_PROFILES.xml to configure the above QoS settings to minimize the memory footprint while still allowing a simple DDS HelloWorld example to function correctly. Even if you are using 4.2e or below, the XML file nicely summarizes which QoS settings you need to touch.

Keywords:
Attachments: