New Member
Posts: 2
Registered: ‎10-18-2006
Message 1 of 3 (96 Views)

Garbage collection

96 Views, 2 Replies
10-18-2006 06:17 PM
I have a COM component developed in Visual C++ 6 (Say COM_SDK6), and a VB.net client is calling this component.

VB.net client program is specifically calling gc.collect method from its code. Due to this, the order in which destructors of COM_SDK6 is getting called gets random. That is, destructors(of different objects exposed by COM_SDK6) get called in any sequence.

Is it a known feature/limitation of .Net? Or I am making some blunder in the code?

Pl share your views.

Distinguished Contributor
Posts: 195
Registered: ‎04-02-2005
Message 2 of 3 (96 Views)

Re: Garbage collection

10-18-2006 07:27 PM in reply to: atin_dhamija
From what I understand you should never call GC from your code, Its expensive and it probably won’t give you the results your looking for. Take a look at Marshal.ReleaseComObject & Marshal.FinalReleaseComObject
New Member
Posts: 2
Registered: ‎10-18-2006
Message 3 of 3 (96 Views)

Re: Garbage collection

10-19-2006 01:07 AM in reply to: atin_dhamija
Hi Danielm,

Thanks a lot for your suggestion. You are right we can control object deletion by calling FinalReleaseComObject.

One more suggestion, in case you can help:
For using COM_SDK6 component, I am doing "Add Reference" for tlb of Say COM_SDK6 in VB.Net. I have neither done any TLBImp nor written any RCW. Is this right?

Thanks again.
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.