Tom,
Unmanaged objects are not garbage collected. The garbage collector has no
knowledge of anything that is unmanaged. Your managed wrappers will get
garbage collected, but not the objects they reference. You will need to
explicitly release the unmanaged objects for them to get cleaned up. You
should be able to do this by calling IUnknown::Release on them.
I hope this is helpful,
Thanks,
Michael Green
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only.
David Browne - 16 Sep 2003 23:38 GMT
> Tom,
>
[quoted text clipped - 3 lines]
> explicitly release the unmanaged objects for them to get cleaned up. You
> should be able to do this by calling IUnknown::Release on them.
Actually, not so. COM interop isn't _that_ broken.
After the Runtime Callable Wrapper for the COM object is garbage collected,
it's finalizer will decrement the reference count on the COM interface. The
COM object will normally be destroyed at that point.
This may be a long time after you wanted the object to be destroyed, so you
can call
Marshal.ReleaseComObject()
To destroy the com object before you let the RCW go out of scope.
David