<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx</link><description>Developers who are accustomed to the IDisposable pattern or to C#’s ‘using’ syntax sometimes ask why COM Interop doesn’t support IDisposable on every Runtime Callable Wrapper (RCW). That way, managed code could indicate that it is finished using the unmanaged</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#51356</link><pubDate>Fri, 18 Apr 2003 01:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51356</guid><dc:creator>Sam Gentile</dc:creator><description>Please read this.</description></item><item><title>RE: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#51357</link><pubDate>Fri, 18 Apr 2003 17:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51357</guid><dc:creator>Sam Gentile</dc:creator><description>Any comments? Do you read your readers? -)

I am very interested in this discussion. Thanks for your blog. It is a bright light in the CLR world.</description></item><item><title>RE: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#51358</link><pubDate>Fri, 18 Apr 2003 17:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51358</guid><dc:creator>Chris Brumme</dc:creator><description>I agree... the marriage of refcounted COM and traced GC is an uneasy one.  We actually spent a lot of time designing  hybrid systems to provide deterministic finalization of managed objects based on injected refcounting by the JIT.  The technical complexity to the CLR was very high; the performance looked like it would be painful; the programming model was lame; and ultimately the approach still didn't give the application what it needed.  As soon as a refcounted object was leaked into a traced reference, its lifetime became non-deterministic (at least until the next GC).

We also considered breaking identity during marshaling.  If we created a different ComObject every time a pUnk was marshaled into managed code, the application could call ReleaseComObject with impunity.  However, this also polluted the programming model.  And imagine the difficulty of calling ReleaseComObject on every reference you acquire in this manner.

This leaves many COM Interop scenarios in a difficult position.  Scenarios #1 &amp;amp; #2 from my post above really do work.  It's scenario #3 which fails.  There are a couple of things we want to do to give some relief in the future.

We want to handle the case where a managed 20-byte ComObject is holding onto a 4 MB unmanaged bit map via a COM object.  Currently, the GC is unaware of the &amp;quot;value&amp;quot; of the unmanaged resource associated with the tiny ComObject and will delay collection.  (Eventually we will notice the overall memory load on the system, but this is beyond the most efficient time for the collection).

So we want to allow the developer to inform the GC of this cost so that we collect more aggressively.  We would also like to provide some services that let you control how many of a scarce resource can be in use at one time.

Obviously I can't give details on either of those efforts.  They should be generally useful outside of COM Interop.  And they should also take some of the scenarios that are currently in #3 and move them to #2.

That still leaves a messy problem with any scenarios that remain in bucket #3.  I'll talk to our Interop team and see if we can come up with patterns that allow different components to usefully agree on whether a COM object is still in use or whether it should be aggressively Release'd.  But I'm not particularly hopeful that we'll find a magic bullet.
</description></item><item><title>RE: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#51359</link><pubDate>Thu, 02 Oct 2003 17:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51359</guid><dc:creator>Yves Reynhout</dc:creator><description>I wonder if I run into any trouble if use Single Threaded Apartment, an RCW and ThreadStatic together?</description></item><item><title>RE: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#51360</link><pubDate>Sun, 19 Oct 2003 17:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51360</guid><dc:creator>ThoughtWorks</dc:creator><description>In a test program, I call Mashal.ReleaseComObj several times and it return -1 at last. What this -1 means? Shouldn't it always stop at 0?</description></item><item><title>Using COM? ReleaseComObject is your friend.</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#85068</link><pubDate>Sat, 06 Mar 2004 10:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:85068</guid><dc:creator>AddressOf.com</dc:creator><description /></item><item><title>re: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#169592</link><pubDate>Wed, 30 Jun 2004 11:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:169592</guid><dc:creator>code weaver</dc:creator><description>Hi Just wanted to know the semantics of Releasecomobject with COM+ usage&lt;br&gt;</description></item><item><title>re: ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#169766</link><pubDate>Wed, 30 Jun 2004 17:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:169766</guid><dc:creator>Chris Brumme</dc:creator><description>There is a detailed discussion of ReleaseComObject combined with EnterpriseServices (managed COM+) in chapter 8 of the excellent Prescriptive Architecture Guidance book on &amp;quot;Improving .NET Application Performance and Scalability&amp;quot;.&lt;br&gt;&lt;br&gt;Chapter 8 can be found at &lt;a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt08.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt08.asp&lt;/a&gt;.  There is also some general guidance about ReleaseComObject in Chapter 7.</description></item><item><title>About COM Interop, having a life et al.</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#252096</link><pubDate>Thu, 04 Nov 2004 06:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:252096</guid><dc:creator>Girish Bharadwaj</dc:creator><description /></item><item><title>bohulu &amp;raquo; links for 2006-11-03</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#942973</link><pubDate>Fri, 03 Nov 2006 17:29:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:942973</guid><dc:creator>bohulu » links for 2006-11-03</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://my.donews.com/bohulu/2006/11/03/BpEpeYNMySrEbUTFVZWqFnjDaMCRhctJsYZw/"&gt;http://my.donews.com/bohulu/2006/11/03/BpEpeYNMySrEbUTFVZWqFnjDaMCRhctJsYZw/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>The Designer Process that Would Not Terminate</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#4677956</link><pubDate>Sat, 01 Sep 2007 02:35:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4677956</guid><dc:creator>The High Altitude Developer</dc:creator><description>&lt;p&gt;I recently was asked to take a look at some VSTO test automation that wasn't behaving correctly on lab&lt;/p&gt;
</description></item><item><title>Bible Versus and Gardens &amp;raquo; cbrumme&amp;#8217;s WebLog : ReleaseComObject</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#8178734</link><pubDate>Thu, 13 Mar 2008 08:04:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8178734</guid><dc:creator>Bible Versus and Gardens » cbrumme’s WebLog : ReleaseComObject</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://biblesplantsblog.info/cbrummes-weblog-releasecomobject/"&gt;http://biblesplantsblog.info/cbrummes-weblog-releasecomobject/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Furl</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#8574151</link><pubDate>Thu, 05 Jun 2008 01:36:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8574151</guid><dc:creator>IWebThereforeIAm</dc:creator><description>&lt;p&gt;[Furl] [DotNetJunkies] [COM interop reference counting in .NET] Excel VBA code to convert collection into an array &amp;gt;Function collectionToArray(c As Collection) As Variant() Dim a() As Variant: ReDim a(0 To c.Count - 1) Dim i As Integer For i =...&lt;/p&gt;
</description></item><item><title> cbrumme s WebLog ReleaseComObject |  Portable Greenhouse</title><link>http://blogs.msdn.com/cbrumme/archive/2003/04/16/51355.aspx#9676879</link><pubDate>Mon, 01 Jun 2009 14:29:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9676879</guid><dc:creator> cbrumme s WebLog ReleaseComObject |  Portable Greenhouse</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://portablegreenhousesite.info/story.php?id=9694"&gt;http://portablegreenhousesite.info/story.php?id=9694&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>