Hi,
James
(or anybody wich already digged into that question or knows a bit about that topic)
i have few questions concerning the use of Finalizer and how they are triggered when the library is recompiled.
It seems that, for PyrObject(s) wich have a Finalizer attached, that the finalizers are not triggered automatically when the lib is recompiled.
For some objects that needs to be finalized properly, because they need to deallocate resources for example, it may results in memory leaks each time the library is recompiled (when there is finalizable PyrObjects left - not marked / or collected yet)
in order to have the finalizer triggered just before the lib is recompiled i added a function member to PyrGC wich calls MajorFlip to the finalizer set then calls ScanFinalizers()
void PyrGC::ForceCollectFinalizers()
{
GCSet *gcs = &mSets[kFinalizerSet];
gcs->MajorFlip();
ScanFinalizers();
}
then calling this at shutdown would trigger the finalizers and correct this behaviour :
gMainVMGlobals->gc->ForceCollectFinalizers();
but i prefer first to ask you :
* is it correct to call it on gMainVMGlobals's GC and make the assumption it won't leave some Finalizer behind ? (althought i did not see any exception to that behaviour until now)
* is it fine to call it on shutdown (either hooking a special primitive at shutdown or coding it directly in shutdownLibrary - example below) ?
void shutdownLibrary();
void shutdownLibrary()
{
closeAllGUIScreens();
aboutToCompileLibrary();
schedStop();
TempoClock_stopAll();
if(gMainVMGlobals && gMainVMGlobals->gc)
gMainVMGlobals->gc->ForceCollectFinalizers();
}
thanks in advance for any answers / tips / confirmation
best,
charles