.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Garbage collection

2 REPLIES 2
Reply
Message 1 of 3
atin_dhamija
399 Views, 2 Replies

Garbage collection

Hi,
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.

Regards.
2 REPLIES 2
Message 2 of 3
dmarcotte4
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
Message 3 of 3
atin_dhamija
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost