<?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>.NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx</link><description>We have reached the end of the .NET Debugging Demos series. And we are going to end it with a review of the last memory leak lab. I am interested to get feedback, either in comments or through email in the contact me section, on what you liked, what you</description><dc:language>sv-SE</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>If broken it is, fix it you should : .NET Debugging Demos - Information and setup instructions</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8353641</link><pubDate>Thu, 03 Apr 2008 15:39:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8353641</guid><dc:creator>If broken it is, fix it you should : .NET Debugging Demos - Information and setup instructions</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx"&gt;http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8354198</link><pubDate>Thu, 03 Apr 2008 18:45:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8354198</guid><dc:creator>Josh Coswell</dc:creator><description>&lt;p&gt;Thanks for the series of posts on debugging. &lt;/p&gt;
&lt;p&gt;I have more insight in this than before.&lt;/p&gt;
&lt;p&gt;Josh Coswell&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://riverasp.net"&gt;http://riverasp.net&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8354225</link><pubDate>Thu, 03 Apr 2008 18:58:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8354225</guid><dc:creator>Mark Hildreth</dc:creator><description>&lt;p&gt;Tess,&lt;/p&gt;
&lt;p&gt;Thanks for the great post! Just one question: &lt;/p&gt;
&lt;p&gt;This example works well because the cache key is always different (because it's a new guid each time). What would happen if the cache key were a hard-coded string? If the RemovedCallback method was static, wouldn't it get called once (for each time the handler was added) since cache item is added in the page load? Here's a pseudo-code example of what I'm talking about:&lt;/p&gt;
&lt;p&gt;private static void RemoveCallback(){}&lt;/p&gt;
&lt;p&gt;//Request 1&lt;/p&gt;
&lt;p&gt;CacheItem.Removed += RemoveCallback;&lt;/p&gt;
&lt;p&gt;//Request 2&lt;/p&gt;
&lt;p&gt;CacheItem.Removed += RemoveCallback;&lt;/p&gt;
&lt;p&gt;//Cache Item Expires&lt;/p&gt;
&lt;p&gt;//Does RemoveCallback is called twice???&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;-Mark&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8354603</link><pubDate>Thu, 03 Apr 2008 21:21:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8354603</guid><dc:creator>Sathya</dc:creator><description>&lt;p&gt;Thanks very much for the outstanding series on debugging .NET applications. The scenarios covered, troubleshooting techniques and the organization of content were excellent . Your labs along with &amp;quot;Debugging .NET 2.0 Applications&amp;quot; are a must read for .NET developers. &amp;nbsp;It would be interesting to see some more labs on debugging threading related issues like deadlocks &amp;amp; race conditions. Hope to see more great articles from you. Thanks again!&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8355838</link><pubDate>Fri, 04 Apr 2008 09:12:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8355838</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;Good question. &lt;/p&gt;
&lt;p&gt;There are two different answers to your question...&lt;/p&gt;
&lt;p&gt;1. &lt;/p&gt;
&lt;p&gt;if you just do CacheItem.Removed += RemovedCallback in a loop or keep doing it on each request you would add many eventhandlers to one CacheItem.Removed and then all the pages associated with those eventhandlers would stick around.&lt;/p&gt;
&lt;p&gt;2. if you do Cache.Add(&amp;quot;myKey&amp;quot;, ..., new CacheItemRemovedCallback...) &amp;nbsp;where &amp;quot;myKey&amp;quot; stays the same everytime only the last news_aspx page would have to stick around. &amp;nbsp;Why? because if you do Cache.Add on a key that already exists, you will remove the old value from cache and add the new one, so the old one no longer exists, and so the onRemove target for the old one has no reason to stick around anymore.&lt;/p&gt;
</description></item><item><title>Link Listing - April 6, 2008</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8364346</link><pubDate>Mon, 07 Apr 2008 06:55:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8364346</guid><dc:creator>Christopher Steen</dc:creator><description>&lt;p&gt;ASP.NET Client Side Templating with jQuery [Via: Rick Strahl ] WPF Unwanted Multiple ClientBin Sub...&lt;/p&gt;
</description></item><item><title>How does the GC work and what are the sizes of the different generations?</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#8402587</link><pubDate>Thu, 17 Apr 2008 15:14:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8402587</guid><dc:creator>If broken it is, fix it you should</dc:creator><description>&lt;p&gt;During our ASP.NET debugging chat there were many questions around the GC and the different generations.&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9022707</link><pubDate>Wed, 29 Oct 2008 21:15:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9022707</guid><dc:creator>Dave</dc:creator><description>&lt;p&gt;Whats the best way to debug IE memory leak? It is such a pain when you building AJAX application that work for IE. And there are no official tool from Microsoft that does it. Even the new IE 8 development tool. Any suggestions?&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9023941</link><pubDate>Thu, 30 Oct 2008 11:07:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9023941</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Dave,&lt;/p&gt;
&lt;p&gt;You can use the same techniques on inetinfo.exe as with other processes. &amp;nbsp;I.e. debugging memory leaks with debug diag or windbg.&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9407353</link><pubDate>Sun, 08 Feb 2009 23:02:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9407353</guid><dc:creator>Srinivas</dc:creator><description>&lt;p&gt;Thank you for all the Great Posts and the Labs...Its Fun to learn Debugging from your posts... :). Wish to see more n more, over the time to come....&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9602257</link><pubDate>Mon, 11 May 2009 13:25:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9602257</guid><dc:creator>Petter</dc:creator><description>&lt;p&gt;Tess,&lt;/p&gt;
&lt;p&gt;I've just finished your Labs series, it is one of the most valuable information source I've ever seen, thank you for your efforts.&lt;/p&gt;
&lt;p&gt;Do you plan to have something on debugging classic asp issues (memory, performance, hang, etc)?&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9602585</link><pubDate>Mon, 11 May 2009 15:19:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9602585</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Petter, &amp;nbsp;very happy to hear that.&lt;/p&gt;
&lt;p&gt;I wasnt planning on doing anything for native issues, but for hangs/perf issues and crashes you troubleshoot them pretty much the same way, and for mem issues you would normally use leaktracking in debug diag to get to the bottom of the issue.&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9852646</link><pubDate>Thu, 30 Jul 2009 02:03:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9852646</guid><dc:creator>Sakar</dc:creator><description>&lt;p&gt;Hi Tess,&lt;/p&gt;
&lt;p&gt;I see increasing private Bytes..So collected the dump. and followed the steps below.&lt;/p&gt;
&lt;p&gt;dumpheap-stat output gives....&lt;/p&gt;
&lt;p&gt;43a209c &amp;nbsp; &amp;nbsp;34708 &amp;nbsp; 3533884 System.Object[]&lt;/p&gt;
&lt;p&gt;43a273c &amp;nbsp; &amp;nbsp; 6749 &amp;nbsp; 7338752 System.Byte[]&lt;/p&gt;
&lt;p&gt;79b946b0 &amp;nbsp; 830459 &amp;nbsp;33038116 System.String&lt;/p&gt;
&lt;p&gt;205158 &amp;nbsp; &amp;nbsp; &amp;nbsp;122 &amp;nbsp;47250460 &amp;nbsp; &amp;nbsp; &amp;nbsp;Free&lt;/p&gt;
&lt;p&gt;Total 1187018 objects&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;So selected Dumpheap -mt and ran GCroot on thread and get following output.&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; !gcroot 054c5000&lt;/p&gt;
&lt;p&gt;Scan Thread 0 (10a0)&lt;/p&gt;
&lt;p&gt;Scan Thread 2 (16cc)&lt;/p&gt;
&lt;p&gt;Scan Thread 3 (13fc)&lt;/p&gt;
&lt;p&gt;Scan Thread 7 (e80)&lt;/p&gt;
&lt;p&gt;Scan Thread 4 (113c)&lt;/p&gt;
&lt;p&gt;Scan Thread 30 (1220)&lt;/p&gt;
&lt;p&gt;Scan Thread 32 (159c)&lt;/p&gt;
&lt;p&gt;Scan Thread 31 (ac0)&lt;/p&gt;
&lt;p&gt;Scan Thread 33 (118)&lt;/p&gt;
&lt;p&gt;Scan Thread 43 (17e4)&lt;/p&gt;
&lt;p&gt;Scan HandleTable 41b0048&lt;/p&gt;
&lt;p&gt;Scan HandleTable 2022a0&lt;/p&gt;
&lt;p&gt;HANDLE(RefCnt):4392238:Root:046a2210(System.Drawing.Internal.GPStream)-&amp;gt;046a21ec(System.IO.MemoryStream)-&amp;gt;054c5000(System.Byte[])&lt;/p&gt;
&lt;p&gt;from the above output can I infer that GC handle is keeping reference to System.Byte[], Beyond this step how can I &lt;/p&gt;
&lt;p&gt;narrow down on the function responsible to keep the reference alive.&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9852647</link><pubDate>Thu, 30 Jul 2009 02:05:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9852647</guid><dc:creator>Sakar</dc:creator><description>&lt;p&gt;For above question Dumpeap -mt was done &amp;nbsp;for system.byte[]&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9879426</link><pubDate>Sat, 22 Aug 2009 01:27:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9879426</guid><dc:creator>Fabio Margarito</dc:creator><description>&lt;p&gt;Hi, Tess!&lt;/p&gt;
&lt;p&gt;In first place, thank's by the posts, they are genials and give a way to pratice this kind of advanced analysis..&lt;/p&gt;
&lt;p&gt;I am with a complicated memory leak issue. I find that system.objects[] are the vilains, but i have dificult to understand de message below. I can't get identifiy the problematic source code. Could you give same tips to give a direction?&lt;/p&gt;
&lt;p&gt;0:006&amp;gt; !gcroot 21811000&lt;/p&gt;
&lt;p&gt;Note: Roots found on stacks may be false positives. Run &amp;quot;!help gcroot&amp;quot; for&lt;/p&gt;
&lt;p&gt;more info.&lt;/p&gt;
&lt;p&gt;ESP:33eeea8:Root:010b3968(System.Collections.Generic.List`1[[System.String, mscorlib]])-&amp;gt;&lt;/p&gt;
&lt;p&gt;21811000(System.Object[])&lt;/p&gt;
&lt;p&gt;=========================================&lt;/p&gt;
&lt;p&gt;i stoped here&lt;/p&gt;
&lt;p&gt;0:006&amp;gt; !do 010b3968&lt;/p&gt;
&lt;p&gt;Name: System.Collections.Generic.List`1[[System.String, mscorlib]]&lt;/p&gt;
&lt;p&gt;MethodTable: 79137270&lt;/p&gt;
&lt;p&gt;EEClass: 7912f680&lt;/p&gt;
&lt;p&gt;Size: 24(0x18) bytes&lt;/p&gt;
&lt;p&gt; (C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)&lt;/p&gt;
&lt;p&gt;Fields:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;MT &amp;nbsp; &amp;nbsp;Field &amp;nbsp; Offset &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type VT &amp;nbsp; &amp;nbsp; Attr &amp;nbsp; &amp;nbsp;Value Name&lt;/p&gt;
&lt;p&gt;7912d8f8 &amp;nbsp;40009c7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Object[] &amp;nbsp;0 instance 21811000 _items&lt;/p&gt;
&lt;p&gt;79102290 &amp;nbsp;40009c8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.Int32 &amp;nbsp;1 instance 101575559 _size&lt;/p&gt;
&lt;p&gt;79102290 &amp;nbsp;40009c9 &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.Int32 &amp;nbsp;1 instance 101575559 _version&lt;/p&gt;
&lt;p&gt;790fd0f0 &amp;nbsp;40009ca &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Object &amp;nbsp;0 instance 00000000 _syncRoot&lt;/p&gt;
&lt;p&gt;7912d8f8 &amp;nbsp;40009cb &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Object[] &amp;nbsp;0 &amp;nbsp; shared &amp;nbsp; static _emptyArray&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt; Domain:Value dynamic statics NYI&lt;/p&gt;
&lt;p&gt; 001599f8:NotInit &amp;nbsp;&amp;lt;&amp;lt;&lt;/p&gt;
&lt;p&gt;How could fiding more issues to identify the memory leak issue?&lt;/p&gt;
&lt;p&gt;Thank's so much&lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9884282</link><pubDate>Wed, 26 Aug 2009 02:13:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9884282</guid><dc:creator>elcarlos14</dc:creator><description>&lt;p&gt;according to what you say above: &amp;quot;A: Any time you hook up an eventhandler to a static object or a long lived object it is better to hook up a static method as the eventhandler rather than an instance method. &amp;nbsp;That way there is no object that needs to stick around for the eventhandler to still be valid. &lt;/p&gt;
&lt;p&gt;In this particular case, everytime we hit the news.aspx page and add the item to cache we will &amp;quot;store&amp;quot; an instance of the news_aspx page in cache and everything it references. &amp;nbsp;The easy solution here would be to make the RemovedCallback static and call News.RemovedCallback rather than this.RemovedCallback.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;The following code posted in MSDN it is wrong?&lt;/p&gt;
&lt;p&gt;public void AddItemToCache(Object sender, EventArgs e) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;itemRemoved = false;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;onRemove = new CacheItemRemovedCallback(this.RemovedCallback);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (Cache[&amp;quot;Key1&amp;quot;] == null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cache.Add(&amp;quot;Key1&amp;quot;, &amp;quot;Value 1&amp;quot;, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration, CacheItemPriority.High, onRemove);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9884736</link><pubDate>Wed, 26 Aug 2009 09:14:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9884736</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Thats correct elcarlos14, &amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the bottom of &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/system.web.caching.cacheitemremovedcallback.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.web.caching.cacheitemremovedcallback.aspx&lt;/a&gt; &amp;nbsp;you will note my comment at the bottom explaining the issue. &lt;/p&gt;
</description></item><item><title>re: .NET Debugging Demos Lab 7: Memory Leak - Review</title><link>http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx#9917829</link><pubDate>Thu, 05 Nov 2009 08:56:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9917829</guid><dc:creator>Francesco</dc:creator><description>&lt;p&gt;Hi Tess,&lt;/p&gt;
&lt;p&gt;your labs are really greats and help me to discover and solve issues found in my applications.&lt;/p&gt;
&lt;p&gt;I would ask you if you have some triks to suggest me in order to analyze a large memory dump file of about 1GB. &lt;/p&gt;
&lt;p&gt;The main problem I'm facing out is due to the time taken by &amp;quot;dumpheap -mt&amp;quot; command to analyze and return about 765k MT objects.&lt;/p&gt;
</description></item></channel></rss>