<?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>Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx</link><description>In my last post I wrote a script to dump out all the ASP.NET requests on the heap. Since one of the most common memory issues I encounter is too much cache or session state I figured that showing you how to retreive session data would be good. A word</description><dc:language>sv-SE</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Link Listing - September 18, 2007</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#4995855</link><pubDate>Wed, 19 Sep 2007 13:44:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4995855</guid><dc:creator>Christopher Steen</dc:creator><description>&lt;p&gt;Link Listing - September 18, 2007&lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#4997344</link><pubDate>Wed, 19 Sep 2007 17:18:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4997344</guid><dc:creator>Jonathan Perret</dc:creator><description>&lt;p&gt;This is very good info, Tess, thanks !&lt;/p&gt;
&lt;p&gt;I don't have any suggestions for useful scripts right now, but I do have two questions that have been nagging me since your blog got me started using SoS :&lt;/p&gt;
&lt;p&gt;1) How does !objsize exactly work and how reliable is it ? It seems you could have many sessions that each report being 100 MB in size while in fact they are all pointing to the same 100 MB block of data ? &lt;/p&gt;
&lt;p&gt;2) Is there an easy way to filter out unreachable objects from !dumpheap etc. ? I'm asking this because I once had a situation where some code was creating hundreds of thousands of objects very fast, and every dump was full of these - it was very difficult to discern which were temporary and which were actual &amp;quot;leaks&amp;quot;. I know of !gcroot but it's slow and not really practical to run it on every object. Ideally there would be a !collect command that would force or simulate a GC on the current heap. But perhaps I am thinking of this in entirely the wrong terms...&lt;/p&gt;
&lt;p&gt;Well that's it, if you feel like addressing either or both I'd be grateful. Otherwise it's no matter, your blog has already been of tremendous help.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;--Jonathan&lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#4997543</link><pubDate>Wed, 19 Sep 2007 17:41:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4997543</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Hi Jonathan,&lt;/p&gt;
&lt;p&gt;1. &amp;nbsp;You are completely right, you cant add upp the result of !objsize since it could potentially be pointing to the same data. i.e. if two items (a and b) both have a pointer to the same object (c) !objsize for a would include the size of c and !objsize for b would also include the size of c.&lt;/p&gt;
&lt;p&gt;However if you have a toplevel object d, pointing to a and b, then the size of c and it's membervariables should only be counted once. &amp;nbsp; &lt;/p&gt;
&lt;p&gt;The same thing is true if you have a double-link, i.e a-&amp;gt;c and c-&amp;gt; &amp;nbsp;(eg. a control points to the parent page and the page has a list of controls which point to the control)&lt;/p&gt;
&lt;p&gt;In this case the size of the control will only be counted once...&lt;/p&gt;
&lt;p&gt;So in short, the !objsize of an item is pretty reliable, but the sum of all objsizes will exceed the total amount of memory on the heap.&lt;/p&gt;
&lt;p&gt;2. &amp;nbsp;No, there isn't an easy way to do this, and yes, gcroot usually takes a long time because it has to traverse a lot of objects...&lt;/p&gt;
&lt;p&gt;The only recommendation I can make there is to run &lt;/p&gt;
&lt;p&gt; &amp;nbsp;GC.Collect &lt;/p&gt;
&lt;p&gt; &amp;nbsp;GC.WaitForPendingFinalizers&lt;/p&gt;
&lt;p&gt; &amp;nbsp;GC.Collect&lt;/p&gt;
&lt;p&gt;before taking the dump, if you are in a testing environment. &amp;nbsp;That way you will clean out as much as possible, leaving you with almost only reacheable objects.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Tess&lt;/p&gt;
</description></item><item><title>September 23rd Links: VS, ASP.NET, ASP.NET AJAX, Silverlight, WPF</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5088739</link><pubDate>Mon, 24 Sep 2007 08:28:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5088739</guid><dc:creator>ScottGu's Blog</dc:creator><description>&lt;p&gt;Here is the latest in my link-listing series . Also check out my ASP.NET Tips, Tricks and Tutorials page&lt;/p&gt;</description></item><item><title>September 23rd Links: VS, ASP.NET, ASP.NET AJAX, Silverlight, WPF</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5088958</link><pubDate>Mon, 24 Sep 2007 08:34:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5088958</guid><dc:creator>ASP.NET</dc:creator><description>&lt;p&gt;Here is the latest in my link-listing series . Also check out my ASP.NET Tips, Tricks and Tutorials page&lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5378661</link><pubDate>Tue, 09 Oct 2007 10:46:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5378661</guid><dc:creator>ASP.NET applications</dc:creator><description>&lt;p&gt;Great blog.&lt;/p&gt;
&lt;p&gt;Somehow in Java it seem to be much easier...&lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5800517</link><pubDate>Wed, 31 Oct 2007 19:17:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5800517</guid><dc:creator>Niktu</dc:creator><description>&lt;p&gt;Awww, my eyes!!! &lt;/p&gt;
&lt;p&gt;Never again textual screenshoots in low quality jpeg, please! :D &lt;/p&gt;
&lt;p&gt;Png or Gif heve their best use right in such situations :)&lt;/p&gt;
&lt;p&gt;... after manadatory amount of complaining ...&lt;/p&gt;
&lt;p&gt;Great info, Thanks!!!&lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5811004</link><pubDate>Thu, 01 Nov 2007 11:30:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5811004</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;:) I completely see what you're saying... I'll update with better pics shortly... &lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#5811282</link><pubDate>Thu, 01 Nov 2007 11:54:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5811282</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Niktu, &lt;/p&gt;
&lt;p&gt;I found the problem with the pics, turns out that the tool i am using for blogging didn't choose to link to the external source but rather stored the pics on the blog but after having turned them into some low res thumbs of the pics. &amp;nbsp;Now it should look a lot better:) &amp;nbsp;I didn't realize this was happening so the pic quality bothered me too, so i'm glad i figured it out... &lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#6204878</link><pubDate>Wed, 14 Nov 2007 13:13:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6204878</guid><dc:creator>parag medsinge</dc:creator><description>&lt;p&gt;I was trying to use the script dumpsessions.txt , i have win2000 Advance server on my machine&lt;/p&gt;
&lt;p&gt;I m getting following error :&lt;/p&gt;
&lt;p&gt;Address expression missing from ':\Aspnetdumps\Scripts\Dumpsessions.txt'&lt;/p&gt;
&lt;p&gt;What will be the possible reason... Its urgent&lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#6250237</link><pubDate>Thu, 15 Nov 2007 12:09:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6250237</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;sounds like the path to your script may be incorrect, perhaps you could post the command you use to load the script so that me or someone else reading the blog can take a look to figure out whats wrong&lt;/p&gt;
</description></item><item><title>My presentation on Troubleshooting ASP.NET production issues at Developer Summit 2008</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8379647</link><pubDate>Fri, 11 Apr 2008 14:24:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8379647</guid><dc:creator>If broken it is, fix it you should</dc:creator><description>&lt;p&gt;The purpose of my presentation was to show some common pitfalls and of course to show off windbg and&lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8841725</link><pubDate>Fri, 08 Aug 2008 00:27:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841725</guid><dc:creator>womp</dc:creator><description>&lt;p&gt;Tess,&lt;/p&gt;
&lt;p&gt;Thanks so much for your awesome labs/tutorials. &amp;nbsp;I went through all of them and have gotten to the point where I'm trying to debug my own asp.net sessions. &lt;/p&gt;
&lt;p&gt;Running these scripts seems to corrupt my dump. &amp;nbsp;When I run DumpSessions.txt I get the following:&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; $$&amp;gt;&amp;lt;DumpSessions.txt&lt;/p&gt;
&lt;p&gt;Session Address:	015c8420&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	017e05a8&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	017ed374&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	01823aa4&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	01826570&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	05693848&lt;/p&gt;
&lt;p&gt;Session Size:	6466088 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	05859788&lt;/p&gt;
&lt;p&gt;Session Size:	208 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;Session Address:	------------------------------&lt;/p&gt;
&lt;p&gt;Session Size:	1 bytes&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
&lt;p&gt;This last entry will hang until I break in Windbg. &amp;nbsp;If I try to run DumpSessionVar on my large session, I get a few good variable outputs and then it starts dumping&lt;/p&gt;
&lt;p&gt;================================================&lt;/p&gt;
&lt;p&gt;Session Variable&lt;/p&gt;
&lt;p&gt;================================================&lt;/p&gt;
&lt;p&gt;Sessionvar Size:	not bytes&lt;/p&gt;
&lt;p&gt;Session Variable:	0167e128&lt;/p&gt;
&lt;p&gt;****&lt;/p&gt;
&lt;p&gt;&amp;lt;Note: this object has an invalid CLASS field&amp;gt;&lt;/p&gt;
&lt;p&gt;Invalid object&lt;/p&gt;
&lt;p&gt;If I try to run either of the scripts, or even a !dumpheap after that, I get the following error message:&lt;/p&gt;
&lt;p&gt;0:018&amp;gt; !dumpheap -stat&lt;/p&gt;
&lt;p&gt;The garbage collector data structures are not in a valid state for traversal. It is either in the &amp;quot;plan phase,&amp;quot; where objects are being moved around, or we are at the initialization or shutdown of the gc heap. Commands related to displaying, finding or traversing objects as well as gc heap segments may not work properly. !dumpheap and !verifyheap may incorrectly complain of heap consistency errors.&lt;/p&gt;
&lt;p&gt;Error requesting GC Heap data&lt;/p&gt;
&lt;p&gt;Unable to build snapshot of the garbage collector state&lt;/p&gt;
&lt;p&gt;Any idea? &amp;nbsp;My dump is from an IIS5 aspnet_wp.exe process with .net 2.0 runtime...&lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8841809</link><pubDate>Fri, 08 Aug 2008 01:21:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841809</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;Hi Womp,&lt;/p&gt;
&lt;p&gt;based on the output of the 2nd script it looks like your version is not matching the version that the script is written for so the offsets are a little bit off... so you would have to change the offsets in the scripts to match your version...&lt;/p&gt;
&lt;p&gt;either way, to get back to a good state you can unload and reload the sos extension, i.e. &amp;nbsp; .unload sos (or path to sos) and then .load sos (or path to sos) again&lt;/p&gt;
</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8841818</link><pubDate>Fri, 08 Aug 2008 01:27:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841818</guid><dc:creator>womp</dc:creator><description>&lt;p&gt;Well I figured out the first part of the problem... &lt;/p&gt;
&lt;p&gt;!dumpheap ... -short was printing out a line of &amp;quot;---------&amp;quot; at the end of the output, which was being taken as one of the sessions in the for loop. &amp;nbsp;Here's some fixed up code for the script:&lt;/p&gt;
&lt;p&gt;.foreach (CurrentSession {!dumpheap -type System.Web.SessionState.InProcSessionState -short}){&lt;/p&gt;
&lt;p&gt; &amp;nbsp;.if ('${CurrentSession}' == '------------------------------')&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; $$.printf /D &amp;quot;Not an Address\n&amp;quot;;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;	.else&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		$$ Increment # of sessions&lt;/p&gt;
&lt;p&gt;		r @$t0 = @$t0+1&lt;/p&gt;
&lt;p&gt;		.printf /D &amp;quot;Session Address:\t&amp;lt;?dml?&amp;gt;&amp;lt;exec cmd=\&amp;quot;$$&amp;gt;a&amp;lt; DumpSessionVar.txt ${CurrentSession}\&amp;quot;&amp;gt;${CurrentSession}&amp;lt;/exec&amp;gt;\n&amp;quot;;&lt;/p&gt;
&lt;p&gt;		.printf &amp;quot;Session Timeout:\t%d\n&amp;quot;, poi(${CurrentSession}+0xc);&lt;/p&gt;
&lt;p&gt;		.foreach /pS 2 /ps 99 (token {!objsize ${CurrentSession}}){.printf &amp;quot;Session Size:\t${token} bytes\n&amp;quot;}&lt;/p&gt;
&lt;p&gt;		.printf &amp;quot;_______________________________________________\n&amp;quot;;&lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;$$.printf /D &amp;quot;An address\n&amp;quot;;&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Now DumpSessionVar.txt gets quite a bit further before bogging down with the invalid class field errors.... but it still doesn't complete properly and ends up in some kind of corrupted state.... &lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8896888</link><pubDate>Tue, 26 Aug 2008 13:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8896888</guid><dc:creator>slmoloch</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Could you help me? I have problem similar to the problem above: &lt;/p&gt;
&lt;p&gt;0:000&amp;gt; !dumpheap -stat&lt;/p&gt;
&lt;p&gt;The garbage collector data structures are not in a valid state for traversal.&lt;/p&gt;
&lt;p&gt;It is either in the &amp;quot;plan phase,&amp;quot; where objects are being moved around, or&lt;/p&gt;
&lt;p&gt;we are at the initialization or shutdown of the gc heap. Commands related to &lt;/p&gt;
&lt;p&gt;displaying, finding or traversing objects as well as gc heap segments may not &lt;/p&gt;
&lt;p&gt;work properly. !dumpheap and !verifyheap may incorrectly complain of heap &lt;/p&gt;
&lt;p&gt;consistency errors.&lt;/p&gt;
&lt;p&gt;Error requesting GC Heap data&lt;/p&gt;
&lt;p&gt;Unable to build snapshot of the garbage collector state&lt;/p&gt;
&lt;p&gt;I am using SOS for .NET 2.0 and dump is got from the same version. &lt;/p&gt;</description></item><item><title>re: Debugging Script: Dumping out ASP.NET Session Contents</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#8896913</link><pubDate>Tue, 26 Aug 2008 13:16:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8896913</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;like the message says you are probably in the middle of a GC in the dump so you can't traverse the heap and thus we can't pick up the requests from the heap&lt;/p&gt;
</description></item><item><title>Developers are from Mars, Ops people are from Venus… or It looked good on paper</title><link>http://blogs.msdn.com/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx#9530659</link><pubDate>Fri, 03 Apr 2009 16:57:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9530659</guid><dc:creator>If broken it is, fix it you should</dc:creator><description>&lt;p&gt;A few weeks back me and Micke (one of our Architect Evangelists) had a session at TechDays where we talked&lt;/p&gt;
</description></item></channel></rss>