You are here: Part 2: Core Concepts > Working with DDS Domains > DomainParticipantFactory > Freeing Resources Used by the DomainParticipantFactory

Freeing Resources Used by the DomainParticipantFactory

The finalize_instance() operation explicitly reclaims resources used by the participant factory singleton (including resources use for QoS profiles).

On many operating systems, these resources are automatically reclaimed by the OS when the program terminates. However, some memory-check tools will flag those resources as unreclaimed. This method provides a way to clean up all the memory used by the participant factory.

Before calling finalize_instance() on a DomainParticipantFactory, all of the participants created by the factory must have been deleted. For a DomainParticipant to be successfully deleted, all Entities created by the participant or by the Entities that the participant created must have been deleted. In essence, the DomainParticipantFactory cannot be deleted until all other Entities have been deleted in an application.

Except for Linux systems: get_instance() and finalize_instance() are UNSAFE on the FIRST call. It is not safe for two threads to simultaneously make the first call to get or finalize the factory instance. Subsequent calls are thread safe.

© 2016 RTI