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




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com