Sagaert,
It's not a destructor, it is a finalizer.
If it never gets called, that doesn't mean that it is never garbage
collected. If you have passed your object reference to the static
SuppressFinalize method on the GC class, then your class will never have the
finalizer called. This is typical when you have implemented the IDispose
interface properly (because your implementation will pass itself to the
SuppressFinalize method so that the finalizer is not called, because you
should have done all the cleanup necessary in the Dispose method) and the
Dispose method is called by people using your class.
The only thing that would prevent GC from collecting an object is
because something is holding a reference to that object, and something is
holding a reference to that object, or it is rooted, and so on, and so on.
You should not depend on the finalizer to indicate when an object has
been GC'ed if you have implemented the IDisposable interface.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Sagaert Johan" <RE*************@hotmail.comwrote in message
news:uE**************@TK2MSFTNGP05.phx.gbl...
Hi
If my destructor of my class (derived from usercontrol ) never gets called
,
does this mean that its not collected by the GC and hence
allocated memory is not freed ?
Is there a way to find out whats prevents the GC to collect this object ?
Johan