<?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>Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx</link><description>Sometimes they run too late.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#135861</link><pubDate>Thu, 20 May 2004 14:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135861</guid><dc:creator>Stephane Rodriguez</dc:creator><description>&lt;br&gt;If the code is made full of implicit construction/destruction that will, because it's unmanaged code, cause spectacular GPFs for any reason, then I am not sure there is any improvement here. I wonder if this isn't a pledge for managed code.&lt;br&gt;&lt;br&gt;Also wonder of next part will cover smart pointers used in class members. Plenty of funny things here.&lt;br&gt;&lt;br&gt;Does anyone if a third party ever came with a COM component manager that would insulate developers from these things without being frightened of GPFs. I know that you can switch to managed code today, yet given that the ROT is of no help without explicit monikers - something that not many people seem to use in the real world - is there any tool to diagnose internal COM life cycle issues?&lt;br&gt;</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#135866</link><pubDate>Thu, 20 May 2004 14:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135866</guid><dc:creator>Jack Mathews</dc:creator><description>While managed code would stop GPF's from happening, there are still PLENTY of logic problems that can and will happen from destruction order issues.  This just happens to be one that crashes, but in managed code or not, you can make objects go to an invalid state and then try to use them to make bad things happen.</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#135870</link><pubDate>Thu, 20 May 2004 14:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135870</guid><dc:creator>Paul Bartlett</dc:creator><description>Slight error (I think). Shouldn't it be p.Release() and p.CoCreateInstance(...). The former is a &amp;quot;well known&amp;quot; gotcha with ATL smart pointers.</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#135890</link><pubDate>Thu, 20 May 2004 15:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135890</guid><dc:creator>Raymond Chen</dc:creator><description>Oops, thanks Paul. I guess this reveals that I don't use ATL smart pointers much...</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#135989</link><pubDate>Thu, 20 May 2004 17:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135989</guid><dc:creator>Mike Dunn</dc:creator><description>p-&amp;gt;Release() actually won't compile. ATL guards against that incorrect usage by having operator-&amp;gt; return a _NoAddRefReleaseOnCComPtr*. The trick is that that class has the AddRef() and Release() methods private, making them inaccessible by the code trying to do p-&amp;gt;Release().</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#136197</link><pubDate>Thu, 20 May 2004 21:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:136197</guid><dc:creator>Catatonic</dc:creator><description>After I read Larry Osterman's post a few weeks ago, I created a class that's almost identical to your CCoInitialize example. To me it feels like the natural solution.</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#136360</link><pubDate>Fri, 21 May 2004 01:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:136360</guid><dc:creator>BeenThere</dc:creator><description>I know this is just an example, but if CoInit was occasionally failing in my code I would want to know why.  Does some unrelated code sometimes set the thread up with a different concurrency model?  An assert might be nice.  Also, shouldn't you be using CoInitializeEx?</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#136367</link><pubDate>Fri, 21 May 2004 01:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:136367</guid><dc:creator>Raymond Chen</dc:creator><description>CoInitialize(NULL) is the same as CoInitializeEx(NULL, COINIT_APARTMENTTHREADED).</description></item><item><title>re: Do you know when your destructors run? Part 1.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#136374</link><pubDate>Fri, 21 May 2004 01:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:136374</guid><dc:creator>BeenThere</dc:creator><description>MSDN says &amp;quot;Applications developed today should call CoInitializeEx rather than CoInitialize,&amp;quot; so that is what I always use.</description></item><item><title>Do you know when your destructors run? Part 2.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/05/20/135841.aspx#136703</link><pubDate>Fri, 21 May 2004 17:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:136703</guid><dc:creator>The Old New Thing</dc:creator><description>Sometimes they don't run at all.</description></item></channel></rss>