<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Memory leak</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Memory leak</description>
  <pubDate>Wed, 10 Jun 2026 19:01:53 -700</pubDate>
  <lastBuildDate>Tue, 07 Sep 2010 05:41:09 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2055</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Memory leak : Hi all,The DataTemplate bug has...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8380#8380</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 07-Sep-2010 at 5:41am<br /><br />Hi all,<div><br></div><div>The DataTemplate bug has been fixed by the Silverlight Team in the september 2010 service release:</div><div><br></div><div><a href="http://timheuer.com/blog/archive/2010/09/01/silverlight-service-release-september-2010-gdr1.aspx" target="_blank">http://timheuer.com/blog/archive/2010/09/01/silverlight-service-release-september-2010-gdr1.aspx</a><br></div><div><br></div><div>And I can confirm&nbsp;<span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">:-)</span></div><div><br></div><div>Best wishes,</div><div>Niels</div>]]>
   </description>
   <pubDate>Tue, 07 Sep 2010 05:41:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8380#8380</guid>
  </item> 
  <item>
   <title>Memory leak : Thanks, Niels. There is much good...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8035#8035</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 10-Aug-2010 at 11:10am<br /><br />Thanks, Niels. There is much good advice here. Some of it is what we call "belt-and-suspenders" ... you take extra steps to cover yourself (to hold your pants up) even though such steps should not be necessary in theory. <DIV>&nbsp;</DIV><DIV>Unhooking from EventAggregator,&nbsp;for example, shouldn't be necessary&nbsp;unless you explicitly defeated its default&nbsp;weakly referenced handlers.</DIV><DIV>&nbsp;</DIV><DIV>Rarely hurts to be careful.</DIV><DIV>&nbsp;</DIV><DIV>We are eager to open a "Good Practices" section of the Wiki ... and your findings would be welcome there when we do.</DIV><DIV>&nbsp;</DIV><DIV>Happy coding!</DIV><span style="font-size:10px"><br /><br />Edited by WardBell - 10-Aug-2010 at 11:12am</span>]]>
   </description>
   <pubDate>Tue, 10 Aug 2010 11:10:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8035#8035</guid>
  </item> 
  <item>
   <title>Memory leak : Hi Ward,I&amp;#039;ve got things working...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8033#8033</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 10-Aug-2010 at 6:37am<br /><br /><div style=": rgb255, 255, 255; margin-left: 1px; margin-top: 1px; margin-right: 1px; margin-bottom: 1px; font-family: Verdana, Arial, Helvetica, sans-serif; color: rgb0, 0, 0; font-weight: normal; font-size: 12px; line-height: 1.4; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; -: n&#111;ne; ">Hi Ward,<div><br></div><div>I've got things working now in my viewmodel. I just newed up an OC&lt;T&gt; up front because indeed I dont really need variable queries at this moment and then add/clear items on the way. 'All' my viewmodels are fixed in a Unit of Work or just used in a general screen like an Article screen or Relationship/party screen.</div><div><br></div><div>I can now create MDI view/model in a tabbed way almost (!) without memory loss (there must always something to figure out :) )</div><div><br></div><div>Learned from experience (most obvious for most I guess) and might not at all be accurate:</div><div>- clean up after use, implement IDisposable on ViewModel, ScreenFactory, Repository, Gateway</div><div>- unsubscribe events from EventAggregator</div><div>- unregister/remove from eventhandlers (like DisplayError, BusyChanged from the PE example)</div><div>- unregister/remove from eventhandler instantiated in XAML of the View (i.e. in XAML:</div><div><br></div><div>... Loaded="PageLoaded" ...</div><div><br></div><div>then in code behind I immediately do:&nbsp;</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private void PageLoaded(object sender, RoutedEventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Loaded -= PageLoaded;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div></div><div><br></div><div>otherwise these objects would not unload or can leak memory.&nbsp;</div><div><br></div><div>I don't know if these things could help anyone, but I'd like to suggest creating some room on your new Wiki with this kind of 'knowledge'/experience as some sort of 'things to read when working with DevForce, Silverlight (and MVVM)'? And create a subsection in your Forum with other users suggestions that might be added in a wiki way. Although on your forum much is discussed, they still are discussions, some with an open end, and a bit unstructured (not the sections themselves of course).</div><div><br></div><div>ah well, babbling too much, so much work to do.</div><div><br></div></div>]]>
   </description>
   <pubDate>Tue, 10 Aug 2010 06:37:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8033#8033</guid>
  </item> 
  <item>
   <title>Memory leak : Thanks, Niels. I repaired the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8031#8031</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 10-Aug-2010 at 2:27am<br /><br />Thanks, Niels. I repaired the link ... as you suggested.]]>
   </description>
   <pubDate>Tue, 10 Aug 2010 02:27:05 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8031#8031</guid>
  </item> 
  <item>
   <title>Memory leak : Thank you for your outstanding...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8030#8030</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 10-Aug-2010 at 2:03am<br /><br />Thank you for your outstanding reply Ward.<DIV>&nbsp;</DIV><DIV>It kept me busy for weeks and exhausted me quite a bit, for I'm new to most of the technologies. However it still is very promising&nbsp;to me especially with the (more than) starter kit 'Prism Explorer' is. For now I'll try this temporary work around (also for learning excitement) and maybe I'll focus on getting PRISM 4 RTC to work for me.</DIV><DIV>&nbsp;</DIV><DIV>The forum the anonymous poster mentioned was my source for the DataTemplate issue, if I had know this was the source for the problem I presented I would have given you the link, sorry. (your link 'link in the silverlightForum' in this post misses this at the end: .aspx#387384)</DIV><DIV>&nbsp;</DIV><DIV>I'll keep a close I on Tim Heuer's twitter.</DIV><DIV>&nbsp;</DIV><DIV>thanks and best regards,</DIV><DIV>Niels</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Tue, 10 Aug 2010 02:03:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8030#8030</guid>
  </item> 
  <item>
   <title>Memory leak : I posted this story on my blog....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8026#8026</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 09-Aug-2010 at 12:31pm<br /><br />I <a href="http://neverindoubtnet.blogspot.com/2010/08/observablecollecti&#111;n-datagrid-memory.html" target="_blank">posted this story on my blog</A>. One of my readers found a link to a Silverlight Forum post that sheds light on the situation and affords hope for a MS fix in the near future. Stay tuned: <DIV>&nbsp;</DIV><DIV>---</DIV><DIV>Thanks, Anonymous, ... nice find!<BR><BR>That <a href="http://forums.silverlight.net/forums/p/171739/387384.aspx#387384%20" target="_blank">link in the SilverlightForum</A> (http://forums.silverlight.net/forums/p/171739/387384.aspx#387384&nbsp;) aligns well with the scenario presented here. The autogenerating DataGrid is likely creating DataTemplates on the fly ("inline") and triggering this unwanted defect.<BR><BR>Looks like the root-cause will affect all controls, including 3rd party controls.<BR><BR>Tim Heuer writes in his July 30 comments "Right now we have a plan &#091;for releasing a service pack that includes a fix to the DataTemplate leak problem&#093; and are driving toward that plan which I've mentioned here as &#091;expected&#093; before end of Summer."<BR><BR>We'll just have to be patient.</DIV><span style="font-size:10px"><br /><br />Edited by WardBell - 10-Aug-2010 at 2:26am</span>]]>
   </description>
   <pubDate>Mon, 09 Aug 2010 12:31:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8026#8026</guid>
  </item> 
  <item>
   <title>Memory leak : You are (mostly) correct and oh...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8023#8023</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 06-Aug-2010 at 3:54pm<br /><br />You are (mostly) correct and oh ... how awful! <DIV>&nbsp;</DIV><DIV>As I demonstrate below, memory is recovered when you clear the EntityManager. It would be recovered if you&nbsp;disposed of the EntityManager itself.&nbsp; I'm not sure why you didn't see these effects.&nbsp;</DIV><DIV><BR>However, you are absolutely right that something horrible is happening. I spent much of the day researching it.</DIV><DIV>&nbsp;</DIV><DIV>The only good part of the story is that it has nothing to do with DevForce. The cause is something in Silverlight, probably in the Silverlight DataGrid.</DIV><DIV>&nbsp;</DIV><DIV>I will explain but it will be a bit of a journey leading ... ultimately ... to a sad-but-necessary&nbsp;workaround.</DIV><DIV>&nbsp;</DIV><DIV>If you want to skip the journey and go right to the destination, the lesson for your code is:</DIV><DIV>&nbsp;</DIV><DIV><strong>Don't reassign the ObservableCollection&lt;T&gt; bound to an&nbsp;ItemsSource; repopulate it!</strong></DIV><DIV>&nbsp;</DIV><DIV>And now ... my sad tale ...</DIV><DIV>&nbsp;</DIV><DIV>The main "ModelExplorer" view binds a Silverlight DataGrid.ItemsSource to the QueryResults property of the supporting&nbsp;ModelExplorerViewModel (the VM).</DIV><DIV>&nbsp;</DIV><DIV>"QueryResults" is defined as IList but is always an ObservableCollection&lt;T&gt; in practice (henceforth written as "OC&lt;T&gt;").</DIV><DIV>&nbsp;</DIV><DIV>The problem&nbsp;starts with the&nbsp;repeated resetting of the QueryResults in the ModelExplorerViewModel after every query. </DIV><DIV>&nbsp;</DIV><DIV>A peculiarity of PrismExplorer (PE)&nbsp;is that the main "ModelExplorer" view could be asked to display objects of any type in the DataGrid. That's its purpose as a demo screen. Your grids typically only show one kind of object. But PE must work with arbitrary query result types.</DIV><DIV>&nbsp;</DIV><DIV>Because those types change, the OC&lt;T&gt; must change to match type.</DIV><DIV>&nbsp;</DIV><DIV>The obvious thing to do was craft a new OC&lt;T&gt; after every query ... one designed for the query results type, assign that new OC to the QueryResults, and raise PropertyChanged on "QueryResults". The DataGrid dutifully hears the call and refreshes its display.</DIV><DIV>&nbsp;</DIV><DIV>Unfortunately, it consumes <strong>an extra 300K every single time</strong>. "300K" is not a misprint. </DIV><DIV>&nbsp;</DIV><DIV>Here's the code with the garbage collection call and logging (<EM>aside: we now inject ILoggerFacade into the VM now so that we can write to the Visual Studio Output window</EM>).</DIV><DIV><PRE style="FONT-FAMILY: c&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">public</SPAN>&nbsp;<SPAN style="COLOR: #2b91af">IList</SPAN>&nbsp;QueryResults&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">get</SPAN>&nbsp;{&nbsp;<SPAN style="COLOR: blue">return</SPAN>&nbsp;_queryResults;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">set</SPAN>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_queryResults = <SPAN style="COLOR: blue">value</SPAN>;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><U>Log(<SPAN style="COLOR: #a31515">"===&nbsp;Total&nbsp;Memory&nbsp;=&nbsp;"</SPAN>&nbsp;+&nbsp;<SPAN style="COLOR: #2b91af">GC</SPAN>.GetTotalMemory(<SPAN style="COLOR: blue">true</SPAN>));</U></strong><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RaisePropertyChanged(<SPAN style="COLOR: #a31515">"QueryResults"</SPAN>,&nbsp;<SPAN style="COLOR: #a31515">"QueryResultsCount"</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectFirstQueryResultsItem();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</PRE></DIV><DIV>If you add this instrumentation, query for "All Customers", and click the "Query" button repeatedly, the Output window will show that your memory consumption is climbing ~300K each time.&nbsp; Here are actual measurement.</DIV><DIV><DIV>&nbsp;</DIV><DIV>&nbsp; Prism Explorer: "=== Total Memory = 3406212";<BR>&nbsp; Prism Explorer: "=== Total Memory = 3914916";<BR>&nbsp; Prism Explorer: "=== Total Memory = 4336668";<BR>&nbsp; Prism Explorer: "=== Total Memory = 4756884";<BR>&nbsp; Prism Explorer: "=== Total Memory = 5177356";<BR>&nbsp; Prism Explorer: "=== Total Memory = 5782900";<BR>&nbsp; Prism Explorer: "=== Total Memory = 6202860";<BR>&nbsp; Prism Explorer: "=== Total Memory = 6616220";<BR>&nbsp; <FONT color=#0000ff>// Cleared the EntityManager<BR></FONT>&nbsp; Prism Explorer: "=== Total Memory = 3655320";<BR>&nbsp; Prism Explorer: "=== Total Memory = 4076292";<BR>&nbsp; Prism Explorer: "=== Total Memory = 4498300";<BR>&nbsp; Prism Explorer: "=== Total Memory = 4918260";<BR>&nbsp; Prism Explorer: "=== Total Memory = 5358912";<BR>&nbsp; <FONT color=#0033ff>// Cleared the EntityManager<BR></FONT>&nbsp; Prism Explorer: "=== Total Memory = 3655384";<BR>&nbsp; </DIV></DIV><DIV>Note that DevForce isn't going anywhere. You are issuing the same query repeatedly and DevForce satisfies it from the EntityManager cache. However, the PE ViewModel is building a new OC&lt;Customer&gt; each time and reassigning QueryResults. The DataGrid is rebinding the ItemsSource to the new OC&lt;Customer&gt; each time ... and chewing up memory each time.</DIV><DIV>&nbsp;</DIV><DIV>If we comment out "_queryResult = value", DevForce and PE will continue to do their things ...&nbsp; DevForce may query the database or satisfy from cache if it can. PE will always build a new OC&lt;T&gt;, assign QueryResults with that OC&lt;T&gt;, raise PropertyChanged, stimulate the DataGrid to rebind to the QueryResults. Exactly the same code paths.</DIV><DIV>&nbsp;</DIV><DIV>The only programmatic difference&nbsp;is that QueryResults always returns the exact same (empty) object.</DIV><DIV>&nbsp;</DIV><DIV><strong>The memory consumption goes flat</strong> ... as it should. </DIV><DIV>&nbsp;</DIV><DIV>Of course it climbs everytime you issue a query that fetches new data; that is to be expected. Press "Clear" to clear the EntityManager cache and memory is recovered.</DIV><DIV>&nbsp;</DIV><DIV><DIV>This is proof enough for me that the memory leak is in Silverlight ... perhaps in the Silverlight DataGrid. Our entities are involved in some way ... that's why clearing the EntityManager cache allows the GC to recover memory. But the DataGrid is clearly chewing up memory at a fast clip without our adding any new entities to memory.</DIV><DIV><DIV><DIV>&nbsp;</DIV><DIV>What could possibly take 300k? The entity data involved are miniscule (it's Northwind!&nbsp; 7 Employees ~90 customers). All entities combined do not weigh 300K. </DIV><DIV>&nbsp;</DIV><DIV>The memory consumption grows by 300K when there are no new entities. Evidently Silverlight or OC is in a deadly embrace with the entities&nbsp;that prevents garbage collection (there are events involved). But even if so&nbsp;... the numbers are staggering. We aren't adding 300K of new data each time we click the button. You can't write enough event handlers to consume 300K. The cost of an OC isn't 300K.&nbsp;</DIV><DIV>&nbsp;</DIV></DIV><DIV>In my research, I tripped over an old WPF blog post (can't find it now)&nbsp;that said something about WPF creating completely new data and control templates for each OC. Now THAT is a fast way to burn memory. I'm betting that Silverlight is creating and caching a complete visual representation of the DataGrid and the associated entities each time I reset the ItemsSource with a new OC&lt;T&gt;!</DIV>&nbsp;</DIV><DIV>I tried a number of things to shake up the binding ... anything to make it let go of whatever it was holding:</DIV><UL><LI>clear the&nbsp;_queryResults ( _queryResults.Clear() ) before re-assigning it with the new OC <LI>clear the _queryResults and&nbsp;set it null before re-assigning it with the new OC <LI>clear the _queryResults, set it null, raise PropertyChanged ... then assign with new OC</LI></UL><DIV>None of these attempts worked.&nbsp; Only pressing "Clear" worked.</DIV><DIV>&nbsp;</DIV><DIV>What to do? The obvious answer is reuse the OC ... and that is the lesson for your application: <strong>Don't reassign the ItemsSource; repopulate it!</strong></DIV><DIV>&nbsp;</DIV><DIV>Of course OC&lt;T&gt; requires strongly typed contents. I tried OC&lt;object&gt; with the intention of simply clearing and refilling it with new results after each query. That executes without error. But it doesn't show anything on screen either ... pretty useless :-).</DIV><DIV>&nbsp;</DIV><DIV>It actually worked if I use List&lt;T&gt; instead of OC&lt;T&gt;. But then I wouldn't have the benefits of&nbsp;ICollectionPropertyChanged and I'd have to manage adds, removals, clears by hand. Yuck.</DIV><DIV>&nbsp;</DIV><DIV><strong>The WorkAround</strong></DIV><DIV>&nbsp;</DIV><DIV>As a last resort, on each pass I check to see if the type of the fresh results matches the element type of the OC. If it does, I can re-populate the OC. If it does not match, I have to replace the ItemsSource with the new OC ... and pay the 300K tax.</DIV><DIV>&nbsp;</DIV><DIV>If you always&nbsp;query for the same type, you'll be fine. You can change the query itself - there are numerous Customer and Employee queries in PE - without paying the tax. It's changing the result type that incurs the tax.</DIV><DIV>&nbsp;</DIV><DIV>I&nbsp;tried to be clever and keep a dictionary of previously used OC types. If I was querying customers, I'd pull out the OC&lt;Customer&gt;; if I was querying&nbsp;employees, I'd pull out the OC&lt;Employee&gt;.&nbsp; That didn't help. The DataGrid doesn't remember OCs that it has seen before.&nbsp;Re-using old OCs&nbsp;didn't change its penchant for&nbsp;devouring another 300K&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>So all I can do is slow it down. If PE starts to blow, you can "Clear" the EntityManager and it will recover.</DIV><DIV>&nbsp;</DIV><DIV>Here's the revised&nbsp;code (which will appear in the next PE release, minus the GC &amp; Log calls)</DIV><DIV><PRE style="FONT-FAMILY: c&#111;nsolas"><PRE style="FONT-FAMILY: c&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">public</SPAN>&nbsp;<SPAN style="COLOR: #2b91af">IList</SPAN>&nbsp;QueryResults&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">get</SPAN>&nbsp;{&nbsp;<SPAN style="COLOR: blue">return</SPAN>&nbsp;_queryResults;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">set</SPAN>&nbsp;{<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResetQueryResults(<SPAN style="COLOR: blue">value</SPAN>);<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log(<SPAN style="COLOR: #a31515">"===&nbsp;Total&nbsp;Memory&nbsp;=&nbsp;"</SPAN>&nbsp;+&nbsp;<SPAN style="COLOR: #2b91af">GC</SPAN>.GetTotalMemory(<SPAN style="COLOR: blue">true</SPAN>));<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RaisePropertyChanged(<SPAN style="COLOR: #a31515">"QueryResults"</SPAN>,&nbsp;<SPAN style="COLOR: #a31515">"QueryResultsCount"</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectFirstQueryResultsItem();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR> <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">private</SPAN>&nbsp;<SPAN style="COLOR: blue">void</SPAN>&nbsp;ResetQueryResults(<SPAN style="COLOR: #2b91af">IList</SPAN>&nbsp;results)&nbsp;{<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">if</SPAN>&nbsp;(<SPAN style="COLOR: blue">null</SPAN>&nbsp;!=&nbsp;_queryResults)&nbsp;_queryResults.Clear();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">if</SPAN>&nbsp;(<SPAN style="COLOR: blue">null</SPAN>&nbsp;==&nbsp;results&nbsp;||&nbsp;0&nbsp;==&nbsp;results.Count)&nbsp;<SPAN style="COLOR: blue">return</SPAN>;<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">var</SPAN>&nbsp;resultsType&nbsp;=&nbsp;<SPAN style="COLOR: #2b91af">TypeHelper</SPAN>.GetItemType(results);<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">if</SPAN>&nbsp;(_queryResultsElementType&nbsp;==&nbsp;resultsType)&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: green">//&nbsp;Same&nbsp;results&nbsp;collection&nbsp;type;&nbsp;can&nbsp;refill&nbsp;it</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">foreach</SPAN>&nbsp;(<SPAN style="COLOR: blue">var</SPAN>&nbsp;item&nbsp;<SPAN style="COLOR: blue">in</SPAN>&nbsp;results)&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_queryResults.Add(item);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<SPAN style="COLOR: blue">else</SPAN>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_queryResults&nbsp;=&nbsp;results;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_queryResultsElementType&nbsp;=&nbsp;resultsType;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">private</SPAN>&nbsp;<SPAN style="COLOR: #2b91af">Type</SPAN>&nbsp;_queryResultsElementType;</PRE></PRE></DIV></DIV><DIV>&nbsp;Here are memory reports:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#0033cc>&nbsp;// Query for All Customers</FONT><BR>&nbsp;Prism Explorer: "=== Total Memory = 3411896"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3425356"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3416064"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3416076"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3416076"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3429460"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3416076"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3415020"<BR><FONT color=#003399>&nbsp;// All Employees</FONT><BR>&nbsp;Prism Explorer: "=== Total Memory = 4203344"<BR>&nbsp;Prism Explorer: "=== Total Memory = 4212964"<BR>&nbsp;Prism Explorer: "=== Total Memory = 4213000"<BR>&nbsp;Prism Explorer: "=== Total Memory = 4213000"<BR>&nbsp;Prism Explorer: "=== Total Memory = 4213000"<BR><FONT color=#003399>&nbsp;// Clear Entity Cache ...&nbsp;followed by All Employees</FONT><BR>&nbsp;Prism Explorer: "=== Total Memory = 3706416"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3588660"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3593996"<BR><FONT color=#0033cc>&nbsp;// First Employee</FONT><BR>&nbsp;Prism Explorer: "=== Total Memory = 3590928"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3604372"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3589676"<BR><FONT color=#0033cc>&nbsp;// Employees named Smith (there are none)</FONT><BR>&nbsp;Prism Explorer: "=== Total Memory = 3605584"</DIV><DIV><FONT color=#0033cc>&nbsp;//&nbsp;All Employees (again)</FONT></DIV><DIV>&nbsp;Prism Explorer: "=== Total Memory = 3757472"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3762120"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3770336"<BR>&nbsp;Prism Explorer: "=== Total Memory = 3762144"<BR></DIV><span style="font-size:10px"><br /><br />Edited by WardBell - 06-Aug-2010 at 4:08pm</span>]]>
   </description>
   <pubDate>Fri, 06 Aug 2010 15:54:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8023#8023</guid>
  </item> 
  <item>
   <title>Memory leak : HelloThis last year I&amp;#039;ve...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8018#8018</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 2055<br /><strong>Posted:</strong> 06-Aug-2010 at 6:30am<br /><br />Hello<div><br></div><div>This last year I've been trying to get DevForce 2010 and Silverlight 4 to work for me, which I bought a year ago (Devforce Universal). But everytime I stumble upon things that don't work for me. Learning moments! Beside some bugs in Silverlight 4 for which work arounds have been presented, I'm now stuck al together with this:</div><div><br></div><div>When ever I bind a datagrid or listbox via a ViewModel to an ObservableCollection which has been build up by the TypeHelper.CreateObservableCollection(results) in a Callback method from a simple query (for example query=Manager.Artikel) and I refresh the records with a new call to the query, I end up consuming memory which will never be released, even not after disposing of the EntityManger, View, Viewmodel, etc. This behavior can be reproduced in your Prism Explorer when querying Customers, Orders, and back a few times. You can see this in Performance Monitor (perfmon) under&nbsp;<span ="Apple-style-span" style="font-family: verdana, Helvetica, sans-serif; line-height: 13px; font-size: 11px; color: rgb68, 68, 68; ">process-&gt;private bytes&nbsp;</span>&nbsp;where the count keeps climbing up.</div><div><br></div><div>At first I (about a month ago) thought that had to do with 'the inline DataTemplate bug', but I have removed al these instances and it still exists.</div><div><br></div><div>Could someone please help me?</div><div>thanks</div><div>Niels</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Fri, 06 Aug 2010 06:30:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2055&amp;PID=8018#8018</guid>
  </item> 
 </channel>
</rss>