
Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Actually, it's not something that I've been able to reproduce while
debugging, as it is difficult to simulate the operating environment. When
the application is under heavy use by our people it occurs more frequently.
I can set up a log to write data to a file in the dispose method, but I'm
not sure what the most useful data to record would be. Also, are there
situations in which the dispose method might not get called? It's a fairly
new area for me, as I've pretty much always worked with managed code and
haven't had to worry about Dispose.
Mike
> Mike,
>
[quoted text clipped - 5 lines]
>
> Mattias
David Levine - 08 Sep 2006 13:19 GMT
You could add some diagnostic test code to capture the creator's callsite
(use the StackWalk to find it), and then write that out if the object gets
finalized or disposed. Or you could save the entire stack trace when the
object is created.
If you implement both Dispose and a finalizer you will get notified when it
either is explicitly destroyed (Dispose) or if it is no longer reachable
(the creator abandoned it) when the Finalizer is called.
So long as the object is reachable the GC will not collect it; it wont just
go away on its own.
> Actually, it's not something that I've been able to reproduce while
> debugging, as it is difficult to simulate the operating environment. When
[quoted text clipped - 20 lines]
>>
>> Mattias