.NETGURU
How to 'Dispose' a RCW?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngmigrate' list.


Anders.Vikstrom@banqit.com
-- Copied from [aspngfreeforall] to [aspngmigrate] by Charles M. Carroll <Click here to reveal e-mail address> --Hi,Does anybody know if there is a way to force or postpone "hurry" the =garbagecollection of runtime callable wrappers for unmanaged COM components?Anders Vikstr=F6mSW Engineering, BANQIT ABhttp://www.banqit.commailto:Click here to reveal e-mail addresse: +46 8 7594737
Reply to this message...
 
    
Joel Mueller
System.Runtime.InteropServices.Marshal.ReleaseComObject(myRCW);

In one situation that involved creating large numbers of COM objects and
using them for a very short time, I got frequent OutOfMemoryException
errors until I explicitly called Marshal.ReleaseComObject on every
single COM object I created.

That includes collections of COM objects. I had to turn something like
this:

Foo[0].bar[1].baz

...into three explicit variables that I could individually release,
before I got rid of the OutofMemoryExceptions.

    - Joel

[Original message clipped]

Reply to this message...
 
    
Anders.Vikstrom@banqit.com
Thanks Joel!

I have now played around with the ReleaseComObject method. I'm happy to see
that I can forcibly free my COM objects. But why can't I rely on the garbage
collector? Does it only see the "small" RCWs and not the real COM/COM+
objects (that can hold a substantial amount of memory)? And, what's worrying
me is that this is quite cumbersome to handle. Especially since you can't
write functions that return COM objects if you want use ReleaseComObject on
each reference (you can't release the object you are returning but the
reference count still goes up).

/Anders

-----Original Message-----
From: Joel Mueller [mailto:Click here to reveal e-mail address]
Sent: den 29 januari 2002 16:59
To: aspngmigrate
Subject: [aspngmigrate] RE: How to 'Dispose' a RCW?

System.Runtime.InteropServices.Marshal.ReleaseComObject(myRCW);

In one situation that involved creating large numbers of COM objects and
using them for a very short time, I got frequent OutOfMemoryException
errors until I explicitly called Marshal.ReleaseComObject on every
single COM object I created.

That includes collections of COM objects. I had to turn something like
this:

Foo[0].bar[1].baz

...into three explicit variables that I could individually release,
before I got rid of the OutofMemoryExceptions.

    - Joel

[Original message clipped]

| [aspngmigrate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngmigrate.asp = JOIN/QUIT

Reply to this message...
 
 
System.OutOfMemoryException
System.Runtime.InteropServices.Marshal




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification