<?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>ASP.NET Debugging : High Memory</title><link>http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx</link><description>Tags: High Memory</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>POP QUIZ: What’s wrong with this code – part 3</title><link>http://blogs.msdn.com/tom/archive/2008/09/23/pop-quiz-what-s-wrong-with-this-code-part-3.aspx</link><pubDate>Tue, 23 Sep 2008 13:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8961276</guid><dc:creator>Tom</dc:creator><slash:comments>66</slash:comments><comments>http://blogs.msdn.com/tom/comments/8961276.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8961276</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8961276</wfw:comment><description>&lt;p&gt;Imagine you are a developer and your boss comes to you complaining that your piece of code has been deemed to be taking up too much memory and causing problems for the application.&amp;#160; You take a look at your code and you see the following, assume that stream is defined above this and is correct:&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; String myConstStr = &lt;span style="color: #006080"&gt;&amp;quot;CurrentFile&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; String stylesheet = &lt;span style="color: #006080"&gt;&amp;quot;..\\..\\XSLTFile1.xslt&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i = 0; i &amp;lt; 1000; i++)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;{&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    XslTransform xslt = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XslTransform();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    xslt.Load(stylesheet);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #008000"&gt;//Load the XML data file.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    String filename = myConstStr + i.ToString() + &lt;span style="color: #006080"&gt;&amp;quot;.xml&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    XPathDocument doc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XPathDocument(filename);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #008000"&gt;//Create an XmlTextWriter to write to the stream.         &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    XmlTextWriter writer = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; XmlTextWriter(stream);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    writer.Formatting = Formatting.Indented;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #008000"&gt;//Transform the file.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    xslt.Transform(doc, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;, writer);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    writer.close();&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;So what is wrong with this snippet of code?&amp;#160; (hint, there may be more then one thing that can be fixed).&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8961276" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Trivia+of+the+Day/default.aspx">Trivia of the Day</category></item><item><title>High Memory part 6 – Fragmentation revisited</title><link>http://blogs.msdn.com/tom/archive/2008/09/17/high-memory-part-6-fragmentation-revisited.aspx</link><pubDate>Wed, 17 Sep 2008 13:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8954457</guid><dc:creator>Tom</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/tom/comments/8954457.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8954457</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8954457</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I have talked about a bunch of commands used to troubleshoot a managed memory problem in the past and given some situations of using them like: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="High memory, CPU, or other performance problems with .NET" href="http://blogs.msdn.com/tom/archive/2007/11/26/high-memory-cpu-or-other-performance-problems-with-net.aspx"&gt;High memory, CPU, or other performance problems with .NET&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="High Memory continued - Datatables" href="http://blogs.msdn.com/tom/archive/2007/12/26/high-memory-continued.aspx"&gt;High Memory continued - Datatables&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="High Memory part 3 - Native Heap" href="http://blogs.msdn.com/tom/archive/2008/02/07/high-memory-part-3.aspx"&gt;High Memory part 3 - Native Heap&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="High Memory part 4 - Managed Strings" href="http://blogs.msdn.com/tom/archive/2008/02/13/high-memory-part-4.aspx"&gt;High Memory part 4 - Managed Strings&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="High Memory part 5 - Fragmentation" href="http://blogs.msdn.com/tom/archive/2008/02/18/high-memory-part-5-fragmentation.aspx"&gt;High Memory part 5 – Fragmentation&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There is another way that we could see a problem that involves fragmentation.&amp;#160; Let’s consider the situation where we see the same situation we saw before, namely:&lt;/p&gt; &lt;a href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_2.png" mce_href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="479" alt="address-summary" src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_thumb.png" width="634" border="0" mce_src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_thumb.png" /&gt;&lt;/a&gt;   &lt;p&gt;&lt;/p&gt;  &lt;p&gt;But we do see a bunch of files listed when we look in &lt;strong&gt;lm&lt;/strong&gt;.&amp;#160; So what should this tell us about the problem?&amp;#160; Well, first off, since the files are showing up in lm, we know the problem isn’t the same as, &lt;a title="Dynamic Assemblies and what to do about them" href="http://blogs.msdn.com/tom/archive/2007/12/05/dynamic-assemblies-and-what-to-do-about-them.aspx"&gt;Dynamic Assemblies and what to do about them&lt;/a&gt;.&amp;#160; So next we would want to look and see specifically what the files are.&lt;/p&gt;  &lt;h3&gt;Situation 1&lt;/h3&gt;  &lt;p&gt;The first common problem that you will see is caused by either have &lt;a href="http://blogs.msdn.com/tom/archive/2007/11/26/high-memory-cpu-or-other-performance-problems-with-net.aspx"&gt;debug=true&lt;/a&gt;, or batch=false is set.&amp;#160; Batch is similar to debug, set in the same place and will tell the compiler to not create one DLL for the entire directory but rather create one DLL for each file we compile.&amp;#160; Underneath, debug=true sets batch=false, so they do the same thing in this regard.&amp;#160; If that is the problem, you will see a bunch of strangely named DLLs in the lm list.&amp;#160; Names like:&lt;/p&gt;  &lt;pre class="code"&gt;  hbdp25u7.dll
  1gxdnryw.dll
  fzgq0g7y.dll
  fhlpqzqm.dll
  su0utu5-.dll
  vhaewyii.dll
  tdkuail7.dll&lt;/pre&gt;

&lt;p&gt;Turning debug off, or batch on will resolve the problem in this situation.&lt;/p&gt;

&lt;h3&gt;Situation 2&lt;/h3&gt;

&lt;p&gt;The second common problem that will cause this is if you have a common framework that you are using in multiple applications.&amp;#160; One common way to do this is the copy the framework files into the bin directory of each application.&amp;#160; This will cause us to create a different in-memory file for each one.&amp;#160; So instead of just having 5 files that make up your framework loaded in memory, you will have 5 * (# of AppDomains) loaded. &lt;/p&gt;

&lt;p&gt;You can identify this problem because in the list of files, you will see the same filename repeated, only some will have some numbers after them:&lt;/p&gt;

&lt;pre class="code"&gt;  MyFramework.dll
  MyFramework_50008012.dll
  MyFramework_50002008.dll
  MyFramework_40101008.dll&lt;/pre&gt;

&lt;p&gt;This is just showing the different versions of the file by showing you the other copies with their base address (load address).&lt;/p&gt;

&lt;p&gt;The easiest solution to this type of problem is to place the framework files into the GAC.&amp;#160; Then you will only have one copy of the files which all the Applications will share.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8954457" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category></item><item><title>How do you test the performance of your web site?</title><link>http://blogs.msdn.com/tom/archive/2008/09/10/how-do-you-test-the-performance-of-your-web-site.aspx</link><pubDate>Wed, 10 Sep 2008 13:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8937133</guid><dc:creator>Tom</dc:creator><slash:comments>22</slash:comments><comments>http://blogs.msdn.com/tom/comments/8937133.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8937133</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8937133</wfw:comment><description>&lt;p&gt;I wanted to get a feel for what tools people are using to test the performance of their website.&amp;#160; My questions are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Do you check page-load times?&amp;#160; &lt;/li&gt;    &lt;li&gt;Do you dig in to see which files are taking the time&lt;/li&gt;    &lt;li&gt;How do you track down a page that uses a lot of memory&lt;/li&gt;    &lt;li&gt;How do you track down a high CPU consuming page&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I don’t want to list any possible tools as I’d like to hear what people are using without me putting any suggestions out.&lt;/p&gt;  &lt;p&gt;If I don’t see some being mentioned, I’ll be sure to bring it up so we have a holistic view of the tools.&lt;/p&gt;  &lt;p&gt;Look forward to seeing what people use.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8937133" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+CPU/default.aspx">High CPU</category></item><item><title>ASP.NET Tips: Finding what is taking up memory</title><link>http://blogs.msdn.com/tom/archive/2008/06/25/asp-net-tips-finding-what-is-taking-up-memory.aspx</link><pubDate>Wed, 25 Jun 2008 13:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8647643</guid><dc:creator>Tom</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/tom/comments/8647643.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8647643</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8647643</wfw:comment><description>&lt;p&gt;There are some times that you want to figure out what is taking up your memory.&amp;#160; There are a few ways that you can do this and some limitations put on this by .NET and ASP.NET.&lt;/p&gt;  &lt;h4&gt;Memory in a dump file&lt;/h4&gt;  &lt;p&gt;If you are looking at a dump file, the first thing you can do is find out how much memory is being taking up by the NT Heaps, Virtual Allocations, Images (EXE and DLL), this is done by using the command: &lt;strong&gt;!address –summary&lt;/strong&gt;: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/ASP.NETTipsFindingwhatistakingofmemory_9F4F/Address-summary2_2.png"&gt;&lt;img title="Address-summary2" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="399" alt="Address-summary2" src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/ASP.NETTipsFindingwhatistakingofmemory_9F4F/Address-summary2_thumb.png" width="544" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here you can see the amount of data that each of these types holds on to.&amp;#160; Another really useful output from this command is being able to see what the largest free region we have in the process.&amp;#160; This is shown at the very bottom of this output.&amp;#160; If that number is less then the size of a new memory allocation, we will fail with an Out Of Memory error.&lt;/p&gt;  &lt;p&gt;Once you have this data, you can start digging deeper on some of these things.&amp;#160; For example, you can run &lt;strong&gt;lm&lt;/strong&gt; to see all the loaded modules in the process.&amp;#160; Most of the time you will want to dig into the virtual allocations (RegionUsageIsVAD).&amp;#160; This is where .NET allocates it’s heaps.&amp;#160; Running &lt;strong&gt;!eeheap -gc&lt;/strong&gt; will show the GC Heap Size so that we can see if all our virtual memory is .NET or something else.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: In a dump file, we cannot figure out the sizes of all individual pages.&amp;#160; This is because these objects hold a reference to their parent object and we will end up getting the size of all the pages, not just the one.&amp;#160; If you need that type of details, see the profilers below. &lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;Memory in a live process&lt;/h4&gt;  &lt;p&gt;To look at memory in a live process, there are a number of different tools you can use depending on the situation.&amp;#160; The most versatile and most common one to use is &lt;a href="http://blogs.msdn.com/tom/archive/2008/06/23/asp-net-and-performance.aspx"&gt;perfmon&lt;/a&gt;.&amp;#160; There are again a few places to focus depending on the situation.&amp;#160; You can look under the &lt;strong&gt;Process &lt;/strong&gt;object and add the &lt;strong&gt;Private Bytes&lt;/strong&gt; and &lt;strong&gt;Virtual Bytes&lt;/strong&gt; to get a good overview of all memory.&amp;#160; If you want to look at .NET, focus in the &lt;strong&gt;.NET CLR Memory&lt;/strong&gt; object.&amp;#160; You can use the &lt;strong&gt;# Total committed Bytes&lt;/strong&gt; and &lt;strong&gt;# Total reserved Bytes&lt;/strong&gt; to see how much memory is being used.&lt;/p&gt;  &lt;p&gt;Other tools you can use to look at memory from a .NET perspective are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="http://www.memprofiler.com/" href="http://www.memprofiler.com/"&gt;http://www.memprofiler.com/&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx"&gt;Visual Studio&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="Download details- CLR Profiler for the .NET Framework 2.0" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&amp;amp;DisplayLang=en"&gt;Download details- CLR Profiler for the .NET Framework 2.0&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="http://msdn.microsoft.com/en-us/netframework/aa569269.aspx" href="http://msdn.microsoft.com/en-us/netframework/aa569269.aspx"&gt;Tools &amp;amp; Utilities on MSDN&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can find a bunch more profilers &lt;a href="http://sharptoolbox.com/categories/profilers-debuggers"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f06%2f25%2fasp-net-tips-finding-what-is-taking-up-memory.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f06%2f25%2fasp-net-tips-finding-what-is-taking-up-memory.aspx" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8647643" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Windows/default.aspx">Windows</category></item><item><title>ASP.NET and Performance</title><link>http://blogs.msdn.com/tom/archive/2008/06/23/asp-net-and-performance.aspx</link><pubDate>Mon, 23 Jun 2008 21:29:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8643250</guid><dc:creator>Tom</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/tom/comments/8643250.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8643250</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8643250</wfw:comment><description>&lt;p&gt;I wanted to talk about monitoring performance in ASP.NET for a bit.&amp;#160; I have already posted a few postings that talk around this issue, namely:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="ASP.NET Debugging - High Memory part 5 - Fragmentation" href="http://blogs.msdn.com/tom/archive/2008/02/18/high-memory-part-5-fragmentation.aspx"&gt;ASP.NET Debugging - High Memory part 5 – Fragmentation&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Debugging - ASP.NET Tips- How to use DebugDiag to track down" href="http://blogs.msdn.com/tom/archive/2008/04/25/asp-net-tips-how-to-use-debugdiag-to-track-down-where-a-performance-problem-is-coming-from.aspx"&gt;ASP.NET Debugging - ASP.NET Tips- How to use DebugDiag to track down&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;But there are some other things to keep in mind.&amp;#160; The best place to look for information on how to watch the performance of an ASP.NET Application is in the “Improving .NET Application Performance” guide on MSDN.&amp;#160; Specifically &lt;a href="http://msdn.microsoft.com/en-us/library/ms998579.aspx"&gt;Chapter 15 – Measuring .NET Application Performance&lt;/a&gt;.&amp;#160; There are a lot of other very useful pieces of information in this.&amp;#160; So I would suggest you review any Chapter that applies to your application.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; If you want to get a description of all the counters, check out: &lt;a title="Performance Counters for ASP.NET" href="http://msdn2.microsoft.com/en-us/library/fxk122b4.aspx"&gt;Performance Counters for ASP.NET&lt;/a&gt; and &lt;a title="Memory Performance Counters" href="http://msdn2.microsoft.com/en-us/library/x2tyfybc.aspx"&gt;Memory Performance Counters&lt;/a&gt;   &lt;p&gt;&lt;/p&gt;  &lt;p&gt;As for how to capture the perfmon data (perfmon is the tool that we use to capture the performance information), take a look at my various posts around the different situations.&amp;#160; This goes through what counters are important in each situation:&lt;/p&gt;  &lt;p&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot" href="http://blogs.msdn.com/tom/archive/2008/05/21/asp-net-tips-what-to-gather-to-troubleshoot.aspx"&gt;ASP.NET Tips- What to gather to troubleshoot&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The main ones to keep an eye on are the memory counters (to watch if memory is staying under control or becoming unbounded) and the ones around the ThreadPool (Queuing, Request Execution Time, etc) to make sure things aren’t getting queued up or blocked in some manner.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f06%2f23%2fasp-net-and-performance.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f06%2f23%2fasp-net-and-performance.aspx" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8643250" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/Crash/default.aspx">Crash</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category><category domain="http://blogs.msdn.com/tom/archive/tags/Hang/default.aspx">Hang</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+CPU/default.aspx">High CPU</category></item><item><title>ASP.NET Tips: What to gather to troubleshoot</title><link>http://blogs.msdn.com/tom/archive/2008/05/21/asp-net-tips-what-to-gather-to-troubleshoot.aspx</link><pubDate>Wed, 21 May 2008 18:38:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8528443</guid><dc:creator>Tom</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/tom/comments/8528443.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8528443</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8528443</wfw:comment><description>&lt;p&gt;So now that I am done with all the individual posts, I thought I would wrap them all together.&amp;#160; So here are all of the posts that I created on gathering information when you are having a problem.&lt;/p&gt;  &lt;p&gt;Please keep in mind that these are geared towards the type of information you would be sending to Microsoft Support.&amp;#160;&amp;#160; So if you are troubleshooting something yourself, you have have some better methods, such as Tracing or Logging.&lt;/p&gt;  &lt;p&gt;So without further ado, here is the complete list:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot – part 1 – High CPU or Hang" href="http://blogs.msdn.com/tom/archive/2008/05/02/asp-net-tips-what-to-gather-to-troubleshoot-part-1-high-cpu.aspx"&gt;High CPU or Hang&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot – part 2 – High Memory" href="http://blogs.msdn.com/tom/archive/2008/05/05/asp-net-tips-what-to-gather-to-troubleshoot-part-2-high-memory.aspx"&gt;High Memory&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot – part 3 – Crash" href="http://blogs.msdn.com/tom/archive/2008/05/06/asp-net-tips-what-to-gather-to-troubleshoot-part-3-crash.aspx"&gt;Crash&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot - part 3a - Crash revisited" href="http://blogs.msdn.com/tom/archive/2008/05/15/asp-net-tips-what-to-gather-to-troubleshoot-part-3a-crash-revisited.aspx"&gt;Crash revisited&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot - part 4 - Deadlocks" href="http://blogs.msdn.com/tom/archive/2008/05/14/asp-net-tips-what-to-gather-to-troubleshoot-part-4-deadlocks.aspx"&gt;Deadlocks&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot - part 5 - OutOfMemoryException" href="http://blogs.msdn.com/tom/archive/2008/05/19/asp-net-tips-what-to-gather-to-troubleshoot-part-5-outofmemoryexception.aspx"&gt;OutOfMemoryException&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a title="ASP.NET Tips- What to gather to troubleshoot - part 6 - Recycle due to memoryLimit" href="http://blogs.msdn.com/tom/archive/2008/05/20/asp-net-tips-what-to-gather-to-troubleshoot-part-6-recycle-due-to-memorylimit.aspx"&gt;Recycle due to memoryLimit&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Hope that these are useful to everyone and hope that you can put these to use.&amp;#160; If you think there is a situation that I haven’t covered, please let me know and I will add it also.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f21%2fasp-net-tips-what-to-gather-to-troubleshoot.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f21%2fasp-net-tips-what-to-gather-to-troubleshoot.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8528443" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/Crash/default.aspx">Crash</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category><category domain="http://blogs.msdn.com/tom/archive/tags/Hang/default.aspx">Hang</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+CPU/default.aspx">High CPU</category></item><item><title>ASP.NET Tips: What to gather to troubleshoot - part 6 - Recycle due to memoryLimit</title><link>http://blogs.msdn.com/tom/archive/2008/05/20/asp-net-tips-what-to-gather-to-troubleshoot-part-6-recycle-due-to-memorylimit.aspx</link><pubDate>Tue, 20 May 2008 19:03:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8523613</guid><dc:creator>Tom</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/tom/comments/8523613.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8523613</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8523613</wfw:comment><description>&lt;p&gt;Here is another situation that you may come across and what to do in order to gather information about it.&lt;/p&gt;  &lt;p&gt;The following steps will configure &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;DebugDiag&lt;/a&gt; to automatically capture a memory dump of the ASPNET_WP.exe process recycling when it exceeds the memoryLimit.&amp;#160; This only applies to the ASPNET_WP.exe process, so if using w3wp.exe, this doesn't apply. The following event is logged when this occurs:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="debug"&gt;&lt;font color="red"&gt;aspnet_wp.exe xxx was recycled because memory 
consumption exceeded 60% of available RAM&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h3&gt;Before the issue occurs&lt;/h3&gt;

&lt;p&gt;A. Download DebugDiag: 
  &lt;br /&gt;====================&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Install the &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;Debug Diagnostic tool&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;The default installation location for the package is C:\Program Files\DebugDiag. It can be changed. &lt;/li&gt;

  &lt;li&gt;Make sure any other monitoring and debugging tools are not running. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;B. Create a Performance Monitor log: 
  &lt;br /&gt;==================================== &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Expand &lt;strong&gt;Performance Logs and Alerts&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Right Click on &lt;strong&gt;Counter Logs&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Choose &lt;strong&gt;New Log Settings...&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Enter a descriptive name &lt;/li&gt;

  &lt;li&gt;Note the log file location for later (or go to the &lt;strong&gt;Log Files&lt;/strong&gt; tab and change the location) &lt;/li&gt;

  &lt;li&gt;Click the &lt;strong&gt;Add&lt;/strong&gt; button &lt;/li&gt;

  &lt;li&gt;Click the &lt;strong&gt;All Counters&lt;/strong&gt; and &lt;strong&gt;All Instances&lt;/strong&gt; radio buttons &lt;/li&gt;

  &lt;li&gt;Select the following from the &lt;strong&gt;Performance Object&lt;/strong&gt; dropdown, being sure to &lt;strong&gt;Add&lt;/strong&gt; each one as you select it: 

    &lt;ul&gt;
      &lt;li&gt;Process &lt;/li&gt;

      &lt;li&gt;Thread &lt;/li&gt;

      &lt;li&gt;Processor &lt;/li&gt;

      &lt;li&gt;Memory &lt;/li&gt;

      &lt;li&gt;.NET CLR Data &lt;/li&gt;

      &lt;li&gt;.NET CLR Exceptions &lt;/li&gt;

      &lt;li&gt;.NET CLR Interop &lt;/li&gt;

      &lt;li&gt;.NET CLR Jit &lt;/li&gt;

      &lt;li&gt;.NET CLR Loading &lt;/li&gt;

      &lt;li&gt;.NET CLR LocksAndThreads &lt;/li&gt;

      &lt;li&gt;.NET CLR Memory &lt;/li&gt;

      &lt;li&gt;.NET CLR Networking &lt;/li&gt;

      &lt;li&gt;.NET CLR Remoting &lt;/li&gt;

      &lt;li&gt;.NET CLR Security &lt;/li&gt;

      &lt;li&gt;ASP.NET &lt;/li&gt;

      &lt;li&gt;ASP.NET Applications &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Close&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the ASP.NET counters, select the version that you are wanting to monitor. Ex. For 1.1 framework, select &lt;strong&gt;ASP.NET v1.1.4322&lt;/strong&gt; and &lt;strong&gt;ASP.NET Applications v1.1.4322&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: For more information on Performance monitor, see KB &lt;a href="http://support.microsoft.com/?id=248345"&gt;248345&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;C. Configure server for the High Memory Event 
  &lt;br /&gt;==================================&lt;/p&gt;

&lt;p&gt;Add the following registry keys. These were added to the .NET Framework so that a breakpoint exception will be thrown when the process recycles due to the above event.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="code"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
DWord: DebugOnHighMem
Value: 1

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
DWord: UnderDebugger
Value: 0&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;C. Configure DebugDiag 
  &lt;br /&gt;=================== &lt;/p&gt;

&lt;p&gt;Configure DebugDiag to capture the memory dump when the BreakPoint Exception is thrown and when the process stops.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open DebugDiag &lt;/li&gt;

  &lt;li&gt;On the Rules tab, click &lt;strong&gt;Add Rule&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;Crash&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;All IIS Processes&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Advanced Exception Configuration&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Add Exception &lt;/strong&gt;&lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;Breakpoint Exception&lt;/strong&gt;, change Action Type to &lt;strong&gt;Full UserDump&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Save and Close&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Advanced Breakpoint Configuration&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Add Breakpoint &lt;/strong&gt;&lt;/li&gt;

  &lt;li&gt;Type &lt;strong&gt;KERNEL32!ExitProcess&lt;/strong&gt; and change Action Type to &lt;strong&gt;Full UserDump&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Save and Close&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click Next through the rest of the wizard &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Inject LeakTrack.dll to capture native leak information:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Click the &lt;strong&gt;Processes&lt;/strong&gt; tab &lt;/li&gt;

  &lt;li&gt;Right-click the ASPNET_WP.exe process, select &lt;strong&gt;Monitor for leaks&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;After the issue occurs&lt;/h3&gt;

&lt;p&gt;The memory dump will automatically get captured.&lt;/p&gt;

&lt;p&gt;A. Stop the Performance Monitor log 
  &lt;br /&gt;=================================== &lt;/p&gt;

&lt;p&gt;In Performance Monitor:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Right click on your log that is now listed under &lt;strong&gt;Counter Logs&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Choose &lt;strong&gt;Stop Log&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f20%2fasp-net-tips-what-to-gather-to-troubleshoot-part-6-recycle-due-to-memorylimit.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f20%2fasp-net-tips-what-to-gather-to-troubleshoot-part-6-recycle-due-to-memorylimit.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8523613" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/Crash/default.aspx">Crash</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category></item><item><title>ASP.NET Tips: What to gather to troubleshoot - part 5 - OutOfMemoryException</title><link>http://blogs.msdn.com/tom/archive/2008/05/19/asp-net-tips-what-to-gather-to-troubleshoot-part-5-outofmemoryexception.aspx</link><pubDate>Mon, 19 May 2008 17:49:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8519108</guid><dc:creator>Tom</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/tom/comments/8519108.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8519108</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8519108</wfw:comment><description>&lt;p&gt;So we already talked about what to gather when you are experiencing &lt;a href="http://blogs.msdn.com/tom/archive/2008/05/05/asp-net-tips-what-to-gather-to-troubleshoot-part-2-high-memory.aspx"&gt;high memory&lt;/a&gt;.&amp;#160; But what if you are actually getting a System.OutOfMemoryException?&amp;#160; Here is how you capture a dump at the time you are running out of memory.&lt;/p&gt;  &lt;p&gt;The following steps will configure &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;DebugDiag&lt;/a&gt; to automatically capture the memory dump when the System.OutOfMemoryException occurs.&lt;/p&gt;  &lt;h3&gt;Before the issue occurs&lt;/h3&gt;  &lt;p&gt;A. Download DebugDiag:    &lt;br /&gt;====================&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Install the &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;Debug Diagnostic tool&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;The default installation location for the package is C:\Program Files\DebugDiag. It can be changed. &lt;/li&gt;    &lt;li&gt;Make sure any other monitoring and debugging tools are not running. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;B. Create a Performance Monitor log:    &lt;br /&gt;==================================== &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Expand &lt;strong&gt;Performance Logs and Alerts&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Right Click on &lt;strong&gt;Counter Logs&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Choose &lt;strong&gt;New Log Settings...&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Enter a descriptive name &lt;/li&gt;    &lt;li&gt;Note the log file location for later (or go to the &lt;strong&gt;Log Files&lt;/strong&gt; tab and change the location) &lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Add&lt;/strong&gt; button &lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;All Counters&lt;/strong&gt; and &lt;strong&gt;All Instances&lt;/strong&gt; radio buttons &lt;/li&gt;    &lt;li&gt;Select the following from the &lt;strong&gt;Performance Object&lt;/strong&gt; dropdown, being sure to &lt;strong&gt;Add&lt;/strong&gt; each one as you select it:       &lt;ul&gt;       &lt;li&gt;Process &lt;/li&gt;        &lt;li&gt;Thread &lt;/li&gt;        &lt;li&gt;Processor &lt;/li&gt;        &lt;li&gt;Memory &lt;/li&gt;        &lt;li&gt;.NET CLR Data &lt;/li&gt;        &lt;li&gt;.NET CLR Exceptions &lt;/li&gt;        &lt;li&gt;.NET CLR Interop &lt;/li&gt;        &lt;li&gt;.NET CLR Jit &lt;/li&gt;        &lt;li&gt;.NET CLR Loading &lt;/li&gt;        &lt;li&gt;.NET CLR LocksAndThreads &lt;/li&gt;        &lt;li&gt;.NET CLR Memory &lt;/li&gt;        &lt;li&gt;.NET CLR Networking &lt;/li&gt;        &lt;li&gt;.NET CLR Remoting &lt;/li&gt;        &lt;li&gt;.NET CLR Security &lt;/li&gt;        &lt;li&gt;ASP.NET &lt;/li&gt;        &lt;li&gt;ASP.NET Applications &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;Close&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;For the ASP.NET counters, select the version that you are wanting to monitor. Ex. For 1.1 framework, select &lt;strong&gt;ASP.NET v1.1.4322&lt;/strong&gt; and &lt;strong&gt;ASP.NET Applications v1.1.4322&lt;/strong&gt;.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: For more information on Performance monitor, see KB &lt;a href="http://support.microsoft.com/?id=248345"&gt;248345&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;C. Configure server to capture OutOfMemoryException    &lt;br /&gt;===========================================&lt;/p&gt;  &lt;p&gt;Add the following registry key. This was added to the .NET Framework so that a breakpoint exception will be thrown when an OutOfMemory condition occurs. This is documented in the following article:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/?id=820745"&gt;820745 Failfast occurs when you experience an &amp;quot;out of memory&amp;quot; condition&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="code"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\
DWord: GCFailFastOnOOM
Value: 2&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;D. Configure DebugDiag 
  &lt;br /&gt;=================== &lt;/p&gt;

&lt;p&gt;Configure DebugDiag to capture the memory dump when the BreakPoint Exception is thrown and when the process stops.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open DebugDiag &lt;/li&gt;

  &lt;li&gt;On the Rules tab, click &lt;strong&gt;Add Rule&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;Crash&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;All IIS Processes&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Advanced Exception Configuration&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Add Exception&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Select &lt;strong&gt;Breakpoint Exception&lt;/strong&gt;, change Action Type to &lt;strong&gt;Full UserDump&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Save and Close&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Advanced Breakpoint Configuration&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Add Breakpoint&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Type &lt;strong&gt;KERNEL32!ExitProcess&lt;/strong&gt; and change Action Type to &lt;strong&gt;Full UserDump&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click &lt;strong&gt;Save and Close&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Click Next through the rest of the wizard &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Inject LeakTrack.dll to capture native leak information:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Click the &lt;strong&gt;Processes&lt;/strong&gt; tab &lt;/li&gt;

  &lt;li&gt;Right-click the ASPNET_WP.exe process (or w3wp.exe if running in IIS 6), select &lt;strong&gt;Monitor for leaks&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;After the issue occurs&lt;/h3&gt;

&lt;p&gt;The memory dump will automatically get captured when the OutOfMemoryException is thrown.&lt;/p&gt;

&lt;p&gt;A. Stop the Performance Monitor log 
  &lt;br /&gt;=================================== &lt;/p&gt;

&lt;p&gt;In Performance Monitor:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Right click on your log that is now listed under &lt;strong&gt;Counter Logs&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;Choose &lt;strong&gt;Stop Log&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f19%2fasp-net-tips-what-to-gather-to-troubleshoot-part-5-outofmemoryexception.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f19%2fasp-net-tips-what-to-gather-to-troubleshoot-part-5-outofmemoryexception.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8519108" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Exceptions/default.aspx">Exceptions</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category></item><item><title>ASP.NET Tips: What to gather to troubleshoot – part 2 – High Memory</title><link>http://blogs.msdn.com/tom/archive/2008/05/05/asp-net-tips-what-to-gather-to-troubleshoot-part-2-high-memory.aspx</link><pubDate>Mon, 05 May 2008 16:28:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8460433</guid><dc:creator>Tom</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/tom/comments/8460433.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8460433</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8460433</wfw:comment><description>&lt;h3&gt;Identifying a Memory leak&lt;/h3&gt;  &lt;p&gt;A Memory Leak in an IIS process (INETINFO.EXE, DLLHOST.EXE, W3WP.EXE) occurs when Memory Usage in Task Manager continues to consume more than 50% of the physical RAM until running out of system memory or until the process stops functioning. &lt;/p&gt;  &lt;p&gt;On heavily-used sites, a continuous growth in memory over the first 24 hours of use is normal. IIS caches much of its data and the TTL on the cache is 24 hours. Since IIS typically uses 50% of available physical RAM (per IIS Process; not the total of all IIS Processes), use this as a guide to identify a memory problem. The steps below will help troubleshoot a memory leak by gathering a memory dump of the leaking process.&lt;/p&gt;  &lt;h3&gt;Important Questions&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;How much RAM is on the machine? &lt;/li&gt;    &lt;li&gt;How much RAM does the leaking IIS process take? &lt;/li&gt;    &lt;li&gt;How long does it take to reproduce? &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Troubleshooting Steps&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;1. Install the Debug Diagnostic tool&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The default install path is C:\Program Files\DebugDiag and can be changed during the installation.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;2. Set up&lt;/b&gt;&lt;b&gt; Performance Monitor Logging&lt;/b&gt; before the issue occurs: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;a) Open DebugDiag (Start -&amp;gt; Programs –&amp;gt; Debug Diagnostics Tool 1.1)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;b) Go to the Tools menu -&amp;gt; Options and Settings&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;c) Select the Performance Log tab&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;d) Click &amp;quot;Enable Performance Counter Data Logging&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;e) Click OK&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; The Data Sampling Interval and time to start monitoring is subjective to when the memory leak reproduces. Due to the log size, work with your Support Professional on a solution where we get the information needed while not overwhelming the server.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3. Create a Memory and Handle Leak Rule&lt;/b&gt; with the following steps: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;a) Open DebugDiag (Start -&amp;gt; Programs -&amp;gt; Debug Diagnostics Tool 1.1)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;b) Select &amp;quot;Memory and Handle Leak&amp;quot; and click Next&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;c) Select the leaking Process and click Next&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;d) In “Configure Tracking Duration”, a Warm-Up time can be specified but if the issue reproduces immediately, select “Start memory tracking immediately”. For “Tracking Time”, specify the time it will take to reproduce the issue. At the end of the specified time, a dump will be created. Make sure “Auto-create a crash rule” is checked.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;e) Click Next&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;f) Click Finish for &amp;quot;Rule Name&amp;quot;. The &amp;quot;Userdump Location&amp;quot; can be changed here. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice the Status is Active. The Userdump Count will increase each time a dump file is created.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;4. Get the Data Manually&lt;/b&gt; if you are not sure when the leak will occur. In DebugDiag, go to the Processes tab, right-click the leaking process and select “Monitor For Leaks”. When the process gets up to 60%-80% of RAM, right-click the leaking process and select &amp;quot;Create Full Userdump”.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;5. Stop &lt;/b&gt;&lt;b&gt;PerfMon Logging&lt;/b&gt; after the dump has finished:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;a) Open DebugDiag (Start -&amp;gt; Programs –&amp;gt; Debug Diagnostics Tool 1.1 )&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;b) Go to the Tools menu -&amp;gt; Options and Settings&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;c) Select the Performance Log tab&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;d) Click &amp;quot;Disable Performance Counter Data Logging&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;e) Click OK&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;6. Analyze the Dump&lt;/b&gt; by selecting the &amp;quot;Advanced Analysis&amp;quot; tab and clicking &amp;quot;Add Data Files&amp;quot;. When the .dmp is added, select the &amp;quot;Memory Pressure Analysis” script and click &amp;quot;Start Analysis&amp;quot;. When finished, a report (.mht) will be created in C:\Program Files\DebugDiag\Reports and displayed in Internet Explorer with the results and recommendation. If using custom DLL’s, the Symbol path (Tools menu -&amp;gt; Options and Settings -&amp;gt; Symbol Search Path) to the custom PDB files can be added. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f05%2fasp-net-tips-what-to-gather-to-troubleshoot-part-2-high-memory.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f05%2f05%2fasp-net-tips-what-to-gather-to-troubleshoot-part-2-high-memory.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8460433" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category></item><item><title>Understanding when to use a Finalizer in your .NET class</title><link>http://blogs.msdn.com/tom/archive/2008/04/25/understanding-when-to-use-a-finalizer-in-your-net-class.aspx</link><pubDate>Sat, 26 Apr 2008 01:04:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8424798</guid><dc:creator>Tom</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/tom/comments/8424798.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8424798</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8424798</wfw:comment><description>&lt;p&gt;A common problem we see when moving to .NET all revolves around the finalizer.&amp;#160; There are a few reasons that this happens:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Developers move from C/C++ to C# and are used to created classes with a constructor and destructor. &lt;/li&gt;    &lt;li&gt;Developers don’t understand when they need to implement Dispose or Finalize and thus create them when they aren’t needed. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Finalization – what is it?&lt;/h3&gt;  &lt;p&gt;So what is Finalization and why is this such an important thing to understand?&amp;#160; Well, there is a good description of it found &lt;a href="http://msdn2.microsoft.com/en-us/library/ms973837.aspx#dotnetgcbasics_topic5"&gt;here&lt;/a&gt;.&amp;#160; Basically it is a way to make sure some code runs when an object gets cleaned up.&lt;/p&gt;  &lt;h3&gt;Why is it necessary?&lt;/h3&gt;  &lt;p&gt;If an object holds onto any unmanaged resources, such as file handles, sockets or database connections, the object is responsible for cleaning them up when it is destroyed.&amp;#160; &lt;strong&gt;This only applies to unmanaged resources!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I would very strongly recommend that you read the documentation for the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.object.finalize.aspx"&gt;Finalize object&lt;/a&gt; very carefully before you use it.&amp;#160; The things to watch for are:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;If you use an unmanaged object and hold a reference to it, you must implement a Finalizer to allow that unmanaged object to be cleaned up.&amp;#160; Otherwise you will leak unmanaged (heap) memory. &lt;/li&gt;    &lt;li&gt;If you create a Finalize method (~Class in C#), even if it is empty, this will put the object on the finalize queue. &lt;/li&gt;    &lt;li&gt;If you have a Finalize method, don’t try to clean up managed objects from it.&amp;#160; That is why most Finalize methods call Dispose(false).&amp;#160; So they don’t clean up any managed objects.&amp;#160; This is because finalized can happen in any order and just cause you hold a reference to an object, doesn’t mean it hasn’t been cleaned up already. &lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;Why is a Finalize method bad?&lt;/h3&gt;  &lt;p&gt;So now we know how we should use the finalizer, but why is it so important to do it correctly?&amp;#160; So items 1 and 3 above are pretty explanatory as to why you would want to do that.&amp;#160; So what is wrong with #2?&lt;/p&gt;  &lt;p&gt;If an object has a finalizer, it will be placed in the FinalizationQueue and is subject so some additional clean-up.&amp;#160; Once the object is no longer referenced on a thread or from a global reference, the next time the Garbage Collector (GC) runs, it will see this object is ready to be collected.&amp;#160; But it can’t collect it yet.&amp;#160; It has to let the Finalizer run first.&amp;#160; So the GC will finish collecting, then the Finalizer will Finalize the object, and then another GC collection will occur.&lt;/p&gt;  &lt;p&gt;This can have a huge affect on performance as you should remember that all managed threads will be stopped waiting on the GC and then the GC will be stopped waiting on the Finalizer thread.&lt;/p&gt;  &lt;p&gt;There is a lot more data out there about Finalization so I encourage you to read about it as much as possible so that you use it in the best way possible.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f25%2funderstanding-when-to-use-a-finalizer-in-your-net-class.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f25%2funderstanding-when-to-use-a-finalizer-in-your-net-class.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8424798" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>ASP.NET Tips: How to identify a COM call that is blocking GC, causing a memory leak</title><link>http://blogs.msdn.com/tom/archive/2008/04/22/asp-net-tips-how-to-identify-a-com-call-that-is-blocking-gc-causing-a-memory-leak.aspx</link><pubDate>Tue, 22 Apr 2008 17:42:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8416603</guid><dc:creator>Tom</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/tom/comments/8416603.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8416603</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8416603</wfw:comment><description>&lt;h4&gt;Problem Description&lt;/h4&gt;  &lt;p&gt;So this is a customer situation we found were the customer was getting an System.OutOfMemoryException.&amp;#160; We were able to reproduce this with a console application that just ran:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;            &lt;span class="kwrd"&gt;For&lt;/span&gt; Iterator = 0 &lt;span class="kwrd"&gt;To&lt;/span&gt; 99999999999
                Regex.IsMatch(CONNECTION_STRING, &lt;span class="str"&gt;&amp;quot;/S&amp;quot;&lt;/span&gt;)
                &lt;span class="rem"&gt;'Create a SQLConnection object then get rid of it&lt;/span&gt;
                Connection.Open()
                Connection.Close()
            &lt;span class="kwrd"&gt;Next&lt;/span&gt; Iterator&lt;/pre&gt;
&lt;style type="text/css"&gt;









.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;It turns out that the SQLConnection object uses some COM objects internally.&amp;#160; This objects need to get collected by the GC (Garbage Collector) but are unable to do so because the COM objects are created on this main STA thread and the finalizer thread cannot call back to the main thread due to this loop.&lt;/p&gt;

&lt;h3&gt;Debugging information&lt;/h3&gt;

&lt;p&gt;Looking at all the threads and look for the Finalizer thread&lt;/p&gt;

&lt;div style="overflow: scroll"&gt;
  &lt;pre class="code"&gt;0:000&amp;gt; !threads
ThreadCount: 3
UnstartedThread: 0
BackgroundThread: 2
PendingThread: 0
DeadThread: 0
                                 PreEmptive   GC Alloc                     Lock     
       ID   ThreadOBJ      State     GC       Context           Domain     Count APT Exception
  0 0x7a0 0x0014d358   0x2006020 Enabled  0x00000000:0x00000000 0x00147b18     0 STA
  2 0xf9c 0x00158010      0xb220 Enabled  0x00000000:0x00000000 0x00147b18     0 MTA (Finalizer)
  6 0xe30 0x0019f460   0x1800220 Enabled  0x00000000:0x00000000 0x00147b18     0 MTA (Threadpool Worker)&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So the Finalizer thread is thread 2.&amp;#160; Looking at the callstack of that thread we see&lt;/p&gt;

&lt;div style="overflow: scroll"&gt;
  &lt;pre class="code"&gt;0:002&amp;gt; kbnL100
 # ChildEBP RetAddr  Args to Child              
00 00bbf74c 77f43741 77e41817 000001e0 00000000 SharedUserData!SystemCallStub+0x4
01 00bbf750 77e41817 000001e0 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 00bbf7c0 77e4168f 000001e0 ffffffff 00000000 kernel32!WaitForSingleObjectEx+0xac
03 00bbf7d0 771d3c39 000001e0 ffffffff 0016d53c kernel32!WaitForSingleObject+0xf
04 00bbf7ec 7726bef4 0018d7c0 00164538 0016d53c ole32!GetToSTA+0x6d
05 00bbf808 7726b087 00bbf8c4 0016d53c 001918f8 ole32!CRpcChannelBuffer::SwitchAptAndDispatchCall+0xc8
06 00bbf8dc 771671c1 0016d53c 00bbf9c4 00bbf9b4 ole32!CRpcChannelBuffer::SendReceive2+0xb6
07 00bbf938 771ac725 0016d53c 00bbf9c4 00bbf9b4 ole32!CAptRpcChnl::SendReceive+0xab
08 00bbf98c 77ce6a4e 00000001 00bbf9c4 00bbf9b4 ole32!CCtxComChnl::SendReceive+0x8f
09 00bbf9a8 77ce6bdf 0018f9f4 00bbf9f0 06000169 rpcrt4!NdrProxySendReceive+0x41
0a 00bbfd78 77ce69cb 77164d98 771d1f38 00bbfdb0 rpcrt4!NdrClientCall2+0x1bc
0b 00bbfd98 77c64fcf 0000000c 00000008 00bbfe1c rpcrt4!ObjectStublessClient+0x89
0c 00bbfda8 771ac365 0018f9f4 00bbfdd0 00000000 rpcrt4!ObjectStubless+0xf
0d 00bbfe1c 772079fb 00000001 7921aa1d 00bbfea4 ole32!CObjectContext::InternalContextCallback+0x10b
0e 00bbfe5c 792190c6 00168018 7921aa1d 00bbfea4 ole32!CObjectContext::ContextCallback+0x6e
0f 00bbff08 79219404 7921aa54 00191058 00000000 mscorwks!CtxEntry::EnterContext+0xb7
10 00bbff30 792192ad 00000000 793e7e48 00000000 mscorwks!ComPlusApartmentCleanupGroup::CleanUpWrappers+0x63
11 00bbff68 7923d2c1 77e4b085 00000000 7923e791 mscorwks!ComPlusWrapperCleanupList::CleanUpWrappers+0x69
12 00bbff74 7923e791 791bbe2e 00000000 00000000 mscorwks!SyncBlockCache::CleanupSyncBlocks+0x85
13 00bbff78 791bbe2e 00000000 00000000 00000000 mscorwks!Thread::DoExtraWorkForFinalizer+0x23
14 00bbffb8 77e4a990 00000000 00000000 00000000 mscorwks!GCHeap::FinalizerThreadStart+0xbb
15 00bbffec 00000000 791ce2dc 00000000 00000000 kernel32!BaseThreadStart+0x34&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In here, frame 0f shows us calling into a COM object to clean it up.&amp;#160; And the frames 04 and 05 show us switching to an STA apartment to make the COM call.&amp;#160; So now lets look at the process and thread that we are switching the COM call to&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="code"&gt;0:002&amp;gt; dd 18d7c0+8 l2
0018d7c8  00000f58 000007a0&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;So now lets see which thread 7a0 is&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="code"&gt;0:002&amp;gt; ~
#  0  Id: f58.7a0 Suspend: 1 Teb: 7ffde000 Unfrozen
   1  Id: f58.bf4 Suspend: 1 Teb: 7ffdd000 Unfrozen
.  2  Id: f58.f9c Suspend: 1 Teb: 7ffdc000 Unfrozen
   3  Id: f58.cb0 Suspend: 1 Teb: 7ffdb000 Unfrozen
   4  Id: f58.75c Suspend: 1 Teb: 7ffda000 Unfrozen
   5  Id: f58.698 Suspend: 1 Teb: 7ffd9000 Unfrozen
   6  Id: f58.e30 Suspend: 1 Teb: 7ffd8000 Unfrozen
   7  Id: f58.b38 Suspend: 1 Teb: 7ffd7000 Unfrozen&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;We can see that thread f58.7a0 is thread 0.&amp;#160; This tells us that the finalizer thread is trying to clean up an object and it is a COM object.&amp;#160; In order to clean up this STA object, we have to call back to it’s owner thread which is thread 0.&lt;/p&gt;

&lt;p&gt;Looking at thread 0 we see&lt;/p&gt;

&lt;div style="overflow: scroll"&gt;
  &lt;pre class="code"&gt;0:000&amp;gt; kbn100
 # ChildEBP RetAddr  Args to Child              
00 0012f2c8 77f4372d 77e41bfa 00000003 0012f318 SharedUserData!SystemCallStub+0x4
01 0012f2cc 77e41bfa 00000003 0012f318 00000001 ntdll!NtWaitForMultipleObjects+0xc
02 0012f374 77161e96 00000003 0012f4f0 00000000 kernel32!WaitForMultipleObjectsEx+0x11a
03 0012f39c 771d36eb 0012f4f0 00000003 0012f3bc ole32!CCliModalLoop::BlockFn+0x2d
04 0012f404 7921a9e4 00162e20 00003a98 00000003 ole32!CoWaitForMultipleHandles+0xc5
05 0012f424 7921a96f 00000000 00003a98 00000003 mscorwks!NT5WaitRoutine+0x51
06 0012f44c 792982dc 00000003 0012f4f0 00000000 mscorwks!MsgWaitHelper+0x62
07 0012f47c 7929883d 00000003 0012f4f0 00000000 mscorwks!Thread::DoAppropriateWaitWorker+0xc1
08 0012f4d0 7933992b 00000003 0012f4f0 00000000 mscorwks!Thread::DoAppropriateWait+0x46
09 0012f534 00f80e8f 00000003 00000000 00000000 mscorwks!WaitHandleNative::CorWaitMultipleNative+0xff
WARNING: Frame IP not in any known module. Following frames may be wrong.
0a 0012f5a8 00febbbd 00000000 00000000 0504b1d4 0xf80e8f
0b 0012f5e8 00edff67 00000000 05041738 0012f6ec 0xfebbbd
0c 0012f62c 00edf44e 00000000 05046adc 0012f6ec 0xedff67
0d 0012f66c 00c51897 00000000 0012f6c8 0012f6ec 0xedf44e
0e 0012f6a8 791d7478 0012f7c0 791dcf66 0012f6fc 0xc51897
0f 0012f6b0 791dcf66 0012f6fc 00000000 0012f6d4 mscorwks!CallDescrWorker+0x30
10 0012f7c0 791dd2ca 008f507b 0015b9a8 0012f7e0 mscorwks!MethodDesc::CallDescr+0x1b6
11 0012f870 791dd336 008f507b 0015b9a8 110028f4 mscorwks!MethodDesc::CallDescr+0x43
12 0012f898 792363e9 0012f928 00000000 0014d358 mscorwks!MethodDesc::Call+0x97
13 0012f950 79238c4c 008f5080 00000001 00000000 mscorwks!ClassLoader::CanAccess+0x207
14 0012fa64 79238d49 0015b9a8 00000000 79041374 mscorwks!ClassLoader::ExecuteMainMethod+0x49d
15 0012fa7c 79238a36 00000000 0012fd70 00000000 mscorwks!Assembly::ExecuteMainMethod+0x21
16 0012fd60 791bcae7 00000001 0012fd90 0012ffe0 mscorwks!SystemDomain::ExecuteMainMethod+0x416
17 0012ffa0 791bc9ea 11000000 00000000 00000000 mscorwks!ExecuteEXE+0x1c0
18 0012ffb0 7917d0b8 00000000 791b0000 0012fff0 mscorwks!_CorExeMain+0x59
19 0012ffc0 77e4f38c 00000000 00000000 7ffdf000 mscoree!_CorExeMain+0x30
1a 0012fff0 00000000 7917d08c 00000000 78746341 kernel32!BaseProcessStart+0x23&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Looking at the managed stack since frames 0a to 12 show what looks like managed code&lt;/p&gt;

&lt;div style="overflow: scroll"&gt;
  &lt;pre class="code"&gt;0:000&amp;gt; !clrstack
Thread 0
ESP         EIP       
0x0012f568  0x7ffe0304 [FRAME: ECallMethodFrame] [DEFAULT] I4 System.Threading.WaitHandle.WaitMultiple(SZArray Class System.Threading.WaitHandle,I4,Boolean,Boolean)
0x0012f580  0x00fec071 [DEFAULT] I4 System.Threading.WaitHandle.WaitAny(SZArray Class System.Threading.WaitHandle,I4,Boolean)
  at [+0xc9] [+0x41]
0x0012f5b4  0x00febbbd [DEFAULT] [hasThis] Class System.Data.SqlClient.SqlInternalConnection System.Data.SqlClient.ConnectionPool.GetConnection(ByRef Boolean)
  at [+0xad] [+0x47]
0x0012f5f0  0x00edff67 [DEFAULT] Class System.Data.SqlClient.SqlInternalConnection System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(Class System.Data.SqlClient.SqlConnectionString,ByRef Boolean)
  at [+0x1a7] [+0xc3]
0x0012f634  0x00edf44e [DEFAULT] [hasThis] Void System.Data.SqlClient.SqlConnection.Open()
  at [+0xce] [+0x44]
0x0012f674  0x00c51897 [DEFAULT] Void ConsoleApplication1.Module1.Main()
  at [+0x9f] [+0x37]
0x0012f9b0  0x791d7478 [FRAME: GCFrame] 
0x0012fa94  0x791d7478 [FRAME: GCFrame] &lt;/pre&gt;
&lt;/div&gt;

&lt;h3&gt;Summary&lt;/h3&gt;

&lt;p&gt;So we can see that ConsoleApplication1.Module1.Main is calling into System.Data.SqlClient.SqlConnection.Open which is waiting for the connection to open.&amp;#160; In a real world scenario you would see it doing different things in a loop but never pumping the message loop.&amp;#160; In order for an STA component to receive calls the thread must pump messages (for more information see the Single-Threaded Apartments (STA) section of &lt;a href="http://msdn2.microsoft.com/en-us/library/ms809311.aspx"&gt;DCOM Architecture&lt;/a&gt;).&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note that any managed object could be using an STA COM object internally (in this case it was the Microsoft SqlConnection object) and there is no easy way to determine if it is doing so.&amp;#160; This means that you should always pump messages on any thread that creates managed objects if you don’t know the internal workings of the managed object (any object you did not develop). &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The following are some methods to determine if a managed object uses COM internally:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using a debugger and setting a breakpoint on COM activation functions in ole32 &lt;/li&gt;

  &lt;li&gt;Use regmon and watch for the process looking up CLSIDs &lt;/li&gt;

  &lt;li&gt;Digging through the IL and looking for COM calls &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Solutions&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;The best solution is to pump messages on the STA thread.&amp;#160; From MSDN we can see easy ways to do this, from the “Blocking Issues” section of &lt;a title="http://msdn2.microsoft.com/en-us/library/74169f59(VS.71).aspx" href="http://msdn2.microsoft.com/en-us/library/74169f59.aspx"&gt;and Unmanaged Threading in Microsoft Windows&lt;/a&gt; 

    &lt;blockquote&gt;
      &lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/system.threading.waithandle.waitone(VS.71).aspx"&gt;WaitHandle.WaitOne&lt;/a&gt;,&lt;b&gt; WaitAny&lt;/b&gt;, &lt;b&gt;WaitAll&lt;/b&gt;, &lt;a href="http://msdn2.microsoft.com/en-us/library/system.threading.monitor.enter(VS.71).aspx"&gt;Monitor.Enter&lt;/a&gt;, &lt;b&gt;Monitor.Block&lt;/b&gt;, &lt;b&gt;Thread.Join&lt;/b&gt;, &lt;a href="http://msdn2.microsoft.com/en-us/library/system.gc.waitforpendingfinalizers(VS.71).aspx"&gt;GC.WaitForPendingFinalizers&lt;/a&gt;, and so on are all responsive to &lt;b&gt;Thread.Interrupt &lt;/b&gt;and to &lt;b&gt;Thread.Abort&lt;/b&gt;. Also, if your thread is in a single-threaded apartment, all these managed blocking operations will correctly pump messages in your apartment while your thread is blocked&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;

  &lt;li&gt;Mark the main thread as an MTA thread &lt;/li&gt;

  &lt;li&gt;If it is not easy to modify the main thread then you can create another thread that will handle the creation of the STA COM objects and will also pump messages. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f22%2fasp-net-tips-how-to-identify-a-com-call-that-is-blocking-gc-causing-a-memory-leak.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f22%2fasp-net-tips-how-to-identify-a-com-call-that-is-blocking-gc-causing-a-memory-leak.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8416603" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET+Tip/default.aspx">ASP.NET Tip</category></item><item><title>Chat Question: What extension to use in what situation</title><link>http://blogs.msdn.com/tom/archive/2008/04/18/chat-question-what-extension-to-use-in-what-situation.aspx</link><pubDate>Fri, 18 Apr 2008 18:34:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408068</guid><dc:creator>Tom</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/tom/comments/8408068.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8408068</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8408068</wfw:comment><description>&lt;p&gt;So we have a bunch of debugger extensions that we need to use depending on the situation.&amp;#160; So here are the extensions that can depend on various situations and when to use which.&amp;#160; The first thing to decide is to load the right DLL for the Framework version and Process version:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="1" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;Extension&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;Process Version&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;Framework Version&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;clr10\sos.dll&lt;/td&gt;        &lt;td valign="top" width="133"&gt;any 32-bit process&lt;/td&gt;        &lt;td valign="top" width="133"&gt;.NET 1.0/.NET 1.1&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Framework\v2.0.50727\sos.dll&lt;/td&gt;        &lt;td valign="top" width="133"&gt;any 32-bit process&lt;/td&gt;        &lt;td valign="top" width="133"&gt;.NET 2.0/.NET 3.0/.NET 3.5&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Framework64\v2.0.50727\sos.dll&lt;/td&gt;        &lt;td valign="top" width="133"&gt;any 64-bit process&lt;/td&gt;        &lt;td valign="top" width="133"&gt;.NET 2.0/.NET 3.0/.NET 3.5&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;IISInfo.dll&lt;/td&gt;        &lt;td valign="top" width="133"&gt;any 32-bit process&lt;/td&gt;        &lt;td valign="top" width="133"&gt;N/A – IIS extension&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Keep in mind that you can run a 32-bit process on a 64-bit operating system.&amp;#160; You would still use the 32-bit files to debug it.&lt;/p&gt;  &lt;p&gt;If you are dealing with a crash, a good starting point is always to run &lt;strong&gt;!analyze -v&lt;/strong&gt;.&amp;#160; This will check for known issues and help to narrow down where the problem is for a crash.&amp;#160; It isn’t perfect for .NET, but will do a great job getting you something to go on.&lt;/p&gt;  &lt;p&gt;Once you have the right extension loaded, then you can start troubleshooting things.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: In the future, I hope to have a new extension that will run on top of SOS.dll and allow you to do some more advanced functions.&amp;#160; This will give similar results to the clr10\sos.dll extension.&amp;#160; But it will be able to run against all versions of the framework.&amp;#160; I am still flushing things out on that, feel free to give me your comments &lt;a href="http://blogs.msdn.com/tom/archive/2008/03/25/asp-net-and-sos.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Keep checking the &lt;a href="http://blogs.msdn.com/tom/archive/2008/04/02/recap-asp-net-blog-chat.aspx"&gt;RECAP- ASP.NET Blog Chat&lt;/a&gt; to see other topics that &lt;a href="http://blogs.msdn.com/Tess"&gt;Tess&lt;/a&gt; or I write about.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f18%2fchat-question-what-extension-to-use-in-what-situation.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f18%2fchat-question-what-extension-to-use-in-what-situation.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8408068" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Chat/default.aspx">Chat</category></item><item><title>Chat Question: Memory Limits for 32-bit and 64-bit processes</title><link>http://blogs.msdn.com/tom/archive/2008/04/10/chat-question-memory-limits-for-32-bit-and-64-bit-processes.aspx</link><pubDate>Thu, 10 Apr 2008 18:00:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8375076</guid><dc:creator>Tom</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/tom/comments/8375076.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8375076</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8375076</wfw:comment><description>&lt;p&gt;During our recent blog chat, there were a number of topics that were asked about and I am going to expand on some of them.&amp;#160; The first one is the memory limits for different processes.&lt;/p&gt;  &lt;p&gt;This really depends on a few different things.&amp;#160; The architecture of the process (32-bit or 64-bit) and also the architecture of the Operating System the process is running on.&amp;#160; For 32-bit it also depends if you use the &lt;a href="http://technet.microsoft.com/en-us/library/bb124810.aspx"&gt;/3GB switch&lt;/a&gt; or not.&lt;/p&gt;  &lt;p&gt;So I broke this up based on these things into the table below, this is the maximum amount of memory available for the process assuming you have that much RAM and Pagefile space.&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="1" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;32-bit OS&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;64-bit OS&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;32-bit process&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;2 GB&lt;/td&gt;        &lt;td valign="top" width="133"&gt;4 GB&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;32-bit process with /3GB&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;3 GB&lt;/td&gt;        &lt;td valign="top" width="133"&gt;N/A&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;64-bit process&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;N/A&lt;/td&gt;        &lt;td valign="top" width="133"&gt;16 TB&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;These process numbers are contingent on how much RAM and disk space you have, so if you have 4 GB of RAM and 4 GB Pagefile, the total memory of all running processes can&amp;#8217;t be greater then 8 GB.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: If you let Windows manage your Pagefile size, when you hit this limit, Windows will try to grow your Pagefile as long as there is disk space available.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;For the amount a .NET application will use before we can expect to see out of memory, those numbers are:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="1" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="131"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="134"&gt;&lt;strong&gt;32-bit OS&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;64-bit OS&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="131"&gt;&lt;strong&gt;32-bit process&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="134"&gt;800-1200 MB&lt;/td&gt;        &lt;td valign="top" width="133"&gt;2800 MB&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="131"&gt;&lt;strong&gt;32-bit process with /3GB&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="134"&gt;1800 MB&lt;/td&gt;        &lt;td valign="top" width="133"&gt;N/A&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="131"&gt;&lt;strong&gt;64-bit process&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="134"&gt;N/A&lt;/td&gt;        &lt;td valign="top" width="133"&gt;2800 MB if using a 4 GB process or more if more RAM (around 70% of RAM + Pagefile)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Keep in mind that although a .NET process can grow this large, if the process is multiple GB in size, it can become very difficult for the Garage Collector to keep up with the memory as Generation 2 will become very large.&amp;#160; I&amp;#8217;ll talk about the generations more in an upcoming post.&lt;/p&gt;  &lt;p&gt;Hopefully that will clear up how much memory each one uses.&lt;/p&gt;  &lt;p&gt;Keep checking the &lt;a title="RECAP- ASP.NET Blog Chat" href="http://blogs.msdn.com/tom/archive/2008/04/02/recap-asp-net-blog-chat.aspx"&gt;RECAP- ASP.NET Blog Chat&lt;/a&gt; to see other topics that &lt;a href="http://blogs.msdn.com/tess"&gt;Tess&lt;/a&gt; or I write about.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f10%2fchat-question-memory-limits-for-32-bit-and-64-bit-processes.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f10%2fchat-question-memory-limits-for-32-bit-and-64-bit-processes.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8375076" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category><category domain="http://blogs.msdn.com/tom/archive/tags/Chat/default.aspx">Chat</category></item><item><title>GDI+ (GdiPlus) and ASP.NET</title><link>http://blogs.msdn.com/tom/archive/2008/03/19/gdi-gdiplus-and-asp-net.aspx</link><pubDate>Wed, 19 Mar 2008 19:31:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8325874</guid><dc:creator>Tom</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/tom/comments/8325874.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=8325874</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=8325874</wfw:comment><description>&lt;p&gt;So we occasionally see customers that are either using System.Drawing themselves in their ASP.NET application or are using controls (like charting controls) that use it.&lt;/p&gt;  &lt;p&gt;Under most circumstances, this works just fine.&amp;#160; But there are times where it does not, and this is cautioned to users on the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.drawing.aspx"&gt;System.Drawing&lt;/a&gt; page on MSDN.&lt;/p&gt;  &lt;p&gt;We recently had a case where GDI+ was causing memory to jump up very quickly.&amp;#160; Looking at the heaps in &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1286"&gt;DebugDiag&lt;/a&gt; showed us:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/GDIGdiPlusandASP.NET_9C8B/GDI-2_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="GDI-2" src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/GDIGdiPlusandASP.NET_9C8B/GDI-2_thumb.png" width="244" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This shows the GdiPlus heap being very fragmented.&amp;#160; And looking at the crt heap, where GDI will allocate things:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/GDIGdiPlusandASP.NET_9C8B/GDI-1_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="GDI-1" src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/GDIGdiPlusandASP.NET_9C8B/GDI-1_thumb.png" width="244" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you look at the full picture, you will see that there is an allocation size of 2,691,448 which is taking up 782.86 MB.&lt;/p&gt;  &lt;p&gt;There is a very good description of this on:    &lt;br /&gt;&lt;a title="http://blogs.msdn.com/carloc/archive/2007/03/17/charting-in-asp-net-alas-dgi-not-supported-from-a-service.aspx" href="http://blogs.msdn.com/carloc/archive/2007/03/17/charting-in-asp-net-alas-dgi-not-supported-from-a-service.aspx"&gt;Charting in ASP.NET (alas: DGI+ not supported in a service)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Note that there are also sites which talk about using System.Drawing on ASP.NET, for example:    &lt;br /&gt;&lt;a title="http://www.geekpedia.com/tutorial123_Working-with-GDIplus-in-ASP.NET.html" href="http://www.geekpedia.com/tutorial123_Working-with-GDIplus-in-ASP.NET.html"&gt;http://www.geekpedia.com/tutorial123_Working-with-GDIplus-in-ASP.NET.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;While this code will work, I would caution that if you run into problems, don't be surprised if this is what is causing the problem, especially if it gets heavy use on your site.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f03%2f19%2fgdi-gdiplus-and-asp-net.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f03%2f19%2fgdi-gdiplus-and-asp-net.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8325874" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category></item><item><title>High Memory part 5 - Fragmentation</title><link>http://blogs.msdn.com/tom/archive/2008/02/18/high-memory-part-5-fragmentation.aspx</link><pubDate>Mon, 18 Feb 2008 19:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7776125</guid><dc:creator>Tom</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/tom/comments/7776125.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=7776125</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=7776125</wfw:comment><description>&lt;P&gt;So in our previous High Memory posts, we have talked about situations that are all causes of memory to appear high when looking at the process in Task Manager or Perfmon.&lt;/P&gt;
&lt;P&gt;But in most situations, you aren't going to be monitoring these tools.&amp;nbsp; So the way you will find out that you are high in memory is that the Web Server will crash and you will see that the exception given was &lt;STRONG&gt;System.OutOfMemoryException&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;There are a number of problems that can cause this, as you can probably guess since this is part 5 of the High Memory blogs.&amp;nbsp; So what if when you look at the process, it isn't taking up much memory, but is still giving you the OutOfMemoryException?&lt;/P&gt;
&lt;H2&gt;Problem 1&lt;/H2&gt;
&lt;P&gt;Let's take a look at a dump with this as the problem.&amp;nbsp; So first we look at !address -summary as always, but don't see much memory in the Virtual Memory or Native Heaps: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_2.png" mce_href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_2.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=479 alt=address-summary src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_thumb.png" width=634 border=0 mce_src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/address-summary_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;But notice that the RegionUsageImage section is pretty high.&amp;nbsp; This is the area where all of our files are.&amp;nbsp; Like the DLLs and EXEs of the actual process.&amp;nbsp; But if you look at the output from &lt;STRONG&gt;lm&lt;/STRONG&gt;, you won't see that much data.&amp;nbsp; So what is going on here?&amp;nbsp; How can we be out of memory, with a lot of memory listed as being images, but list modules (lm) doesn't show that many?&lt;/P&gt;
&lt;P&gt;The answer is something we have discussed in the past, &lt;A title="Dynamic Assemblies and what to do about them" href="http://blogs.msdn.com/tom/archive/2007/12/05/dynamic-assemblies-and-what-to-do-about-them.aspx" mce_href="http://blogs.msdn.com/tom/archive/2007/12/05/dynamic-assemblies-and-what-to-do-about-them.aspx"&gt;Dynamic Assemblies and what to do about them&lt;/A&gt;.&amp;nbsp; If we run the same command that is in the troubleshooting section of that post we can see:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/dumpdomain-stat_2.png" mce_href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/dumpdomain-stat_2.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=184 alt=dumpdomain-stat src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/dumpdomain-stat_thumb.png" width=634 border=0 mce_src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/dumpdomain-stat_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;And we can clearly see from this that we have a lot of dynamic assemblies.&amp;nbsp; So now we just follow the same steps as in that previous post to see what they are and reduce the amount of them that we are using.&lt;/P&gt;
&lt;H2&gt;Problem 2&lt;/H2&gt;
&lt;P&gt;There is another type of Fragmentation that we could see.&amp;nbsp; That we first mentioned in &lt;A title="High Memory part 4" href="http://blogs.msdn.com/tom/archive/2008/02/13/high-memory-part-4.aspx" mce_href="http://blogs.msdn.com/tom/archive/2008/02/13/high-memory-part-4.aspx"&gt;High Memory part 4&lt;/A&gt;.&amp;nbsp; That is high memory in .NET, but when you look at the output of &lt;STRONG&gt;!dumpheap -stat&lt;/STRONG&gt; you see something like:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/fragmentation_2.png" mce_href="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/fragmentation_2.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=379 alt=fragmentation src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/fragmentation_thumb.png" width=634 border=0 mce_src="http://blogs.msdn.com/blogfiles/tom/WindowsLiveWriter/HighMemorypart5Fragmentation_DE84/fragmentation_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;From this we can see that the largest amount of memory is being taking up by System.Free (Free in the list).&amp;nbsp; This is a special object that is used by .NET when an object is no longer being referenced, but we haven't been able to recapture the memory yet.&amp;nbsp; So why haven't we been able to recapture the memory?&amp;nbsp; Well the reason is because of the blocks that are printed below the report.&amp;nbsp; These are the actual Free blocks that are in .NET and the object that is after them is also listed.&amp;nbsp; Theses are typically caused by objects being pinned.&amp;nbsp; There is a very good description of the situation &lt;A href="https://blogs.msdn.com/yunjin/archive/2004/01/27/63642.aspx" mce_href="https://blogs.msdn.com/yunjin/archive/2004/01/27/63642.aspx"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;For this particular dump, the fix was to install the hotfix, &lt;A href="http://support.microsoft.com/?id=831138" mce_href="http://support.microsoft.com/?id=831138"&gt;831138&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f02%2f18%2fhigh-memory-part-5-fragmentation.aspx"&gt;&lt;IMG alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f02%2f18%2fhigh-memory-part-5-fragmentation.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7776125" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/High+Memory/default.aspx">High Memory</category></item></channel></rss>