Enabling monitoring library in an application may result in a valgrind memory leak report.

When enabling RTI Monitoring library via the QoS file, a Connext DDS application might report a memory leak when using valgrind for memory usage analysis. An example of the valgrind output for this memory leak is found at the end of this article. An example of the QoS XML used to load RTI Monitoring library is the following:

<property>
    <value>
        <element>
            <name>rti.monitor.library</name>
            <value>rtimonitoring</value>
        </element>
        <element>
            <name>rti.monitor.create_function</name>
            <value>RTIDefaultMonitor_create</value>
        </element>
    </value>
</property> 

Connext DDS calls dlopen/dlclose to load/unload the RTI monitoring library. This memory leak appears to be related to a bug in valgrind when using -lpthread and loading/unloading an external library. This issue is recorded at the following link:

https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1160352

As described in the above link, this memory leak can be reported by valgrind when using a simple non-RTI Connext test application. The above link also has an example of a non-RTI reproducing application. 

Please contact RTI support if you have any questions.

Valgrind results showing memory leak

==3184== HEAP SUMMARY:
==3184== in use at exit: 32 bytes in 1 blocks
==3184== total heap usage: 127,629 allocs, 127,628 frees, 168,366,860 bytes allocated
==3184==
==3184== Searching for pointers to 1 not-freed blocks
==3184== Checked 1,119,216 bytes
==3184==
==3184== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==3184== at 0x62E1975: calloc (vg_replace_malloc.c:711)
==3184== by 0x64EC61F: _dlerror_run (in /usr/lib64/libdl-2.17.so)
==3184== by 0x64EC050: dlopen@@GLIBC_2.2.5 (in /usr/lib64/libdl-2.17.so)
==3184== by 0x86A3F88: RTIOsapiLibrary_open (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddscore.so)
==3184== by 0x7C323B1: DDS_DomainParticipantMonitoring_initializeMonitoringLibrary (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddsc.so)
==3184== by 0x7C7E871: DDS_Registry_assertRecord (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddsc.so)
==3184== by 0x7C3301D: DDS_DomainParticipantMonitoring_initializeI (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddsc.so)
==3184== by 0x7C59E6D: DDS_DomainParticipant_createI (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddsc.so)
==3184== by 0x7C28A88: DDS_DomainParticipantFactory_create_participant_disabledI (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddsc.so)
==3184== by 0x77E75EE: DDSDomainParticipant_impl::create_disabledI(DDSDomainParticipantFactory*, unsigned char*, unsigned char, int, DDS_DomainParticipantQos const&, DDSDomainParticipantListener*, unsigned int) (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddscpp.so)
==3184== by 0x77E7D88: DDSDomainParticipant_impl::createI(DDSDomainParticipantFactory*, int, DDS_DomainParticipantQos const&, DDSDomainParticipantListener*, unsigned int) (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddscpp.so)
==3184== by 0x77DFB5B: DDSDomainParticipantFactory_impl::create_participant(int, DDS_DomainParticipantQos const&, DDSDomainParticipantListener*, unsigned int) (in /ftproot/artifact_cache/x86_64Linux3gcc4.8/rti/5.3.0.16/rti_connext_dds-5.3.0/lib/x64Linux3gcc4.8.2/libnddscpp.so)
==3184==
==3184== LEAK SUMMARY:
==3184== definitely lost: 0 bytes in 0 blocks
==3184== indirectly lost: 0 bytes in 0 blocks
==3184== possibly lost: 0 bytes in 0 blocks
==3184== still reachable: 32 bytes in 1 blocks
==3184== suppressed: 0 bytes in 0 blocks
==3184==
==3184== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==3184== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Platform: