|
||
To ensure that ECom unloads plug-in DLLs when they are no longer required, and releases associated memory, clients should follow these cleanup rules:
They should delete instantiated objects obtained from an interface when they are no longer required.
Processes, such as servers, applications and test programs, must call
REComSession::FinalClose()
before they shut down to allow
ECom to do its final cleanup steps.
The function should be called after all instantiated interface objects have been deleted. If your program performs checks for heap memory or handle leaks on shutdown, then the function should be called before these.
If you are using ECom in a library, you should call
REComSession::FinalClose()
within your library's shutdown
function, if it has one. This makes the library's use of ECom transparent to
its clients, which then do not have to call the FinalClose()
themselves. It is not an error if both a library and its clients call
FinalClose()
.
Note that FinalClose()
must never be called
from within the destructor of an interface or plug-in implementation class.
This could unload the DLL containing the destructor code and cause a system
crash.