diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-E3A80D62-09A5-502D-AB55-6AB2A5623465.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-E3A80D62-09A5-502D-AB55-6AB2A5623465.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,53 @@ + + + + + +Cleaning-up +MemoryTo ensure the plug-in framework unloads the plug-in DLLs when they +are no longer required and releases associated memory, the clients should +follow an explicit memory cleanup procedure. The main purpose is to release +memory and close handles held on unused plug-in implementations and their +associated DLLs. The memory clean-up should be performed after all instantiated +interface objects have been deleted. +

The plug-in framework client-side library implements a deferred +cleanup mechanism in the client process to handle destroyed plug-ins. Following +a call to REComSession::DestroyedImplementation() in the +destructor, the plug-in’s reference count is decremented to zero and the client-side +library has a “last destroyed last plug-in” garbage pointer. The internal +framework memory associated with the garbage plug-in is released. The handles +on the DLL are closed at the beginning of the next call to REComSession::DestroyedImplementation(). +This chain of deferred cleanup in the client thread requires the final plug-in +in the garbage queue to be released. Hence there is a requirement for explicit +memory clean-up. The memory clean-up is performed by the clients of the plug-in +framework. The destructor of the interface implementation deletes the +instantiated objects obtained from an interface when they are no longer required +by calling the static function REComSession::DestroyedImplementation(). inline CExampleInterfaceDefinition::~CExampleInterfaceDefinition() + { + REComSession::DestroyedImplementation(iDtor_ID_Key); + }

+ + +Call REComSession::FinalClose() before shut down +to ensure the plug-in framework executes the final cleanup steps. + Note: REComSession::FinalClose() should not be +called from a plug-in implementation class destructor, especially following +a REComSession::DestroyedImplementation(). There is a risk +that the plug-in's supporting DLL may immediately be unloaded by the Kernel +due to the closure of RLibrary handles. It can result in a KERN-EXEC if the +destructor call stack is still inside the DLL that is unloaded. + + +If the plug-in framework is used in a library, then REComSession::FinalClose() should +be invoked within the library's shutdown function. This makes the library's +use of plug-in framework transparent to the clients. +It is not an error if both the library and client call REComSession::FinalClose(). + + +
\ No newline at end of file