<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: What&#8217;s Wrong With This Picture?</title> <atom:link href="http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Wed, 08 Feb 2012 11:42:42 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: TomC</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47208</link> <dc:creator>TomC</dc:creator> <pubDate>Thu, 15 Jul 2010 11:34:59 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47208</guid> <description>@Rob Kent &#039;What context was it in?&#039;:
This piece of code can be found in the &#039;LayoutUpdated&#039; event of &#039;System.Windows.FrameworkElement&#039;.This event is actually a static event, but exposed as an instance event! The actual static list of handlers is of type &#039;List&#039; and in addition to that the &#039;FrameworkElement&#039;-instance also keeps an instance of List with all of the attached eventhandlers.
To make it even stranger, this List is not kept as a normal instance field, but rather via a DependencyProperty (I have no idea why!).Eventually when the event is raised (via unmanaged code) only the static &#039;List&#039; is used. I guess that the actual reference of the eventhandler is also kept in memory to prevent that the &quot;reference-tree&quot; connected to the eventhandler is garbagecollected. This is probably done so to make it behave like a normal instance event instead of a static weak-event, so this means you have to remove/detach the eventhandler to prevent memory leaks (as in a normal event).The &#039;WeakRefSTRUCT&#039; is used as a helper to be able to remove an eventhandler from both the static and the instance lists more easily I guess.This is my best guess as to why this &#039;WeakRefSTRUCT&#039; thing is used, so I might be completely wrong about it.
Anyway you should take a look at the code in Reflector to view the entire &#039;LayoutUpdated&#039; code.</description> <content:encoded><![CDATA[<p>@Rob Kent &#8216;What context was it in?&#8217;:<br
/> This piece of code can be found in the &#8216;LayoutUpdated&#8217; event of &#8216;System.Windows.FrameworkElement&#8217;.</p><p>This event is actually a static event, but exposed as an instance event! The actual static list of handlers is of type &#8216;List&#8217; and in addition to that the &#8216;FrameworkElement&#8217;-instance also keeps an instance of List with all of the attached eventhandlers.<br
/> To make it even stranger, this List is not kept as a normal instance field, but rather via a DependencyProperty (I have no idea why!).</p><p>Eventually when the event is raised (via unmanaged code) only the static &#8216;List&#8217; is used. I guess that the actual reference of the eventhandler is also kept in memory to prevent that the &#8220;reference-tree&#8221; connected to the eventhandler is garbagecollected. This is probably done so to make it behave like a normal instance event instead of a static weak-event, so this means you have to remove/detach the eventhandler to prevent memory leaks (as in a normal event).</p><p>The &#8216;WeakRefSTRUCT&#8217; is used as a helper to be able to remove an eventhandler from both the static and the instance lists more easily I guess.</p><p>This is my best guess as to why this &#8216;WeakRefSTRUCT&#8217; thing is used, so I might be completely wrong about it.<br
/> Anyway you should take a look at the code in Reflector to view the entire &#8216;LayoutUpdated&#8217; code.</p> ]]></content:encoded> </item> <item><title>By: Rob Kent</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47203</link> <dc:creator>Rob Kent</dc:creator> <pubDate>Thu, 15 Jul 2010 10:33:38 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47203</guid> <description>What context was it in? You can sort of imagine someone thinking they wanted to retrieve value after weak reference has disappeared, even though weak reference can never be garbage collected because of the hard reference to value.And why not use a struct? Mystifying.</description> <content:encoded><![CDATA[<p>What context was it in? You can sort of imagine someone thinking they wanted to retrieve value after weak reference has disappeared, even though weak reference can never be garbage collected because of the hard reference to value.</p><p>And why not use a struct? Mystifying.</p> ]]></content:encoded> </item> <item><title>By: Mark Knell</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47108</link> <dc:creator>Mark Knell</dc:creator> <pubDate>Wed, 14 Jul 2010 19:48:28 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47108</guid> <description>That&#039;s in Silverlight?! Gaaa.I also enjoy that WeakRefSTRUCT, all protestations to the contrary, is not in fact a struct.</description> <content:encoded><![CDATA[<p>That&#8217;s in Silverlight?! Gaaa.</p><p>I also enjoy that WeakRefSTRUCT, all protestations to the contrary, is not in fact a struct.</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47104</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 14 Jul 2010 19:20:04 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47104</guid> <description>@Alit&#039;s in a core piece of Silverlightthat probably explains why there are so many memory leaks with Silverlight, no matter how hard you try to avoid them</description> <content:encoded><![CDATA[<p>@Al</p><p>it&#8217;s in a core piece of Silverlight</p><p>that probably explains why there are so many memory leaks with Silverlight, no matter how hard you try to avoid them</p> ]]></content:encoded> </item> <item><title>By: Al</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47103</link> <dc:creator>Al</dc:creator> <pubDate>Wed, 14 Jul 2010 19:18:35 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47103</guid> <description>This &lt;i&gt;must&lt;/i&gt; be code someone wrote to test unexpected behavior occurring with a WeakReference, and then they accidentally never cleaned up the debugging cruft. I have a hard time believing someone would know enough about .NET to try using WeakReferences and then purposefully write code that fugly.</description> <content:encoded><![CDATA[<p>This <i>must</i> be code someone wrote to test unexpected behavior occurring with a WeakReference, and then they accidentally never cleaned up the debugging cruft. I have a hard time believing someone would know enough about .NET to try using WeakReferences and then purposefully write code that fugly.</p> ]]></content:encoded> </item> <item><title>By: Diego Mijelshon</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47075</link> <dc:creator>Diego Mijelshon</dc:creator> <pubDate>Wed, 14 Jul 2010 15:16:19 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47075</guid> <description>Looks like somebody missed the point of &lt;em&gt;weak&lt;/em&gt; references...</description> <content:encoded><![CDATA[<p>Looks like somebody missed the point of <em>weak</em> references&#8230;</p> ]]></content:encoded> </item> <item><title>By: Adam</title><link>http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/comment-page-1/#comment-47073</link> <dc:creator>Adam</dc:creator> <pubDate>Wed, 14 Jul 2010 15:04:29 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/2010/07/whats-wrong-with-this-picture-4/#comment-47073</guid> <description>Nice, semi-weak reference :D</description> <content:encoded><![CDATA[<p>Nice, semi-weak reference <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/12 queries in 0.012 seconds using disk: basic
Object Caching 419/422 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-02-08 18:15:09 -->
