R
Richard
Hi,
I'm writing an MS Outlook 2000 Addin in C#. I have
created C# classes that monitor folder events and do other
business logic. Things work fine until I want to exit
Outlook. When I exit Outlook I have to force 2 garbage
collection cycles in order for all of my folder monitor
classes to get cleaned up {else Outlook will not unload
from memory}. In other words my OnDisconnect() method
looks something like this:
{
// recursively null out all folder objects
myOutlookMonitor = null;
Trace.Writeln("First GC.Collect()...");
GC.Collect();
GC.WaitForPendingFinalizers();
Trace.Writeln("Second GC.Collect()...");
GC.Collect();
GC.WaitForPendingFinalizers();
}
I put Trace calls into the destructors for my folder
monitor classes and indeed I have confirmed that several
of the destructors do not get called until the second
GC.Collect() is issued...
Does anybody know why I would need to issue 2 GC.Collect()
calls? Outlook does succesfully unload from memory after
I issue the second GC.Collect() and it will NOT unload
from memory unless I issue 2 GC.Collect() calls....
--Richard
I'm writing an MS Outlook 2000 Addin in C#. I have
created C# classes that monitor folder events and do other
business logic. Things work fine until I want to exit
Outlook. When I exit Outlook I have to force 2 garbage
collection cycles in order for all of my folder monitor
classes to get cleaned up {else Outlook will not unload
from memory}. In other words my OnDisconnect() method
looks something like this:
{
// recursively null out all folder objects
myOutlookMonitor = null;
Trace.Writeln("First GC.Collect()...");
GC.Collect();
GC.WaitForPendingFinalizers();
Trace.Writeln("Second GC.Collect()...");
GC.Collect();
GC.WaitForPendingFinalizers();
}
I put Trace calls into the destructors for my folder
monitor classes and indeed I have confirmed that several
of the destructors do not get called until the second
GC.Collect() is issued...
Does anybody know why I would need to issue 2 GC.Collect()
calls? Outlook does succesfully unload from memory after
I issue the second GC.Collect() and it will NOT unload
from memory unless I issue 2 GC.Collect() calls....
--Richard