<?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>Kristoffer's tidbits : .NET</title><link>http://blogs.msdn.com/kristoffer/archive/tags/.NET/default.aspx</link><description>Tags: .NET</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>It's 10 pm, do you know what your JITter is doing?</title><link>http://blogs.msdn.com/kristoffer/archive/2009/11/13/it-s-10-pm-do-you-know-what-your-jitter-is-doing.aspx</link><pubDate>Fri, 13 Nov 2009 21:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922260</guid><dc:creator>Kristoffer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/kristoffer/comments/9922260.aspx</comments><wfw:commentRss>http://blogs.msdn.com/kristoffer/commentrss.aspx?PostID=9922260</wfw:commentRss><description>&lt;p&gt;Ever have that awkward feeling like you don't know what actually gets executed as a result of your managed code? Visual Studio allows you to inspect the JITted code easily but does require a few tweaks first:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First set your project to build in &lt;b&gt;Release&lt;/b&gt; mode.&lt;/li&gt;
&lt;li&gt;Next go to &lt;b&gt;Tools|Options|Debugging&lt;/b&gt; and uncheck both &lt;b&gt;Suppress JIT optimization on module load (Managed only)&lt;/b&gt; and &lt;b&gt;Enable Just My Code (Managed only)&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Now you can run your project and set a breakpoint where you want to look at code and go to &lt;b&gt;Debug | Windows | Disassembly&lt;/b&gt; to get an annotated disassembly like the following:&amp;nbsp;&lt;/p&gt;
&lt;div style="background: white none repeat scroll 0% 0%; font-family: Courier New; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void Main(string[] args)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DoTest();&lt;br&gt;&lt;span style="color: gray;"&gt;00000000 push ebp &lt;br&gt;00000001 mov ebp,esp &lt;br&gt;00000003 push esi &lt;br&gt;00000004 call dword ptr ds:[00159B7Ch] &lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(s);&lt;br&gt;&lt;span style="color: gray;"&gt;0000000a mov esi,dword ptr ds:[037D5B20h] &lt;br&gt;00000010 call 6B20BE78 &lt;br&gt;00000015 mov ecx,eax &lt;br&gt;00000017 mov edx,esi &lt;br&gt;00000019 mov eax,dword ptr [ecx] &lt;br&gt;0000001b call dword ptr [eax+000000D8h] &lt;br&gt;00000021 pop esi &lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;span style="color: gray;"&gt;00000022 pop ebp &lt;br&gt;00000023 ret &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922260" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/kristoffer/archive/tags/.NET/default.aspx">.NET</category></item><item><title>OutOfMemoryException is special</title><link>http://blogs.msdn.com/kristoffer/archive/2009/02/25/outofmemoryexception-is-special.aspx</link><pubDate>Wed, 25 Feb 2009 20:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9444365</guid><dc:creator>Kristoffer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/kristoffer/comments/9444365.aspx</comments><wfw:commentRss>http://blogs.msdn.com/kristoffer/commentrss.aspx?PostID=9444365</wfw:commentRss><description>&lt;p&gt;Consider the humble OutOfMemoryException and its most common usage. If it is thrown when the system is well and truly out of memory then how would the system allocate enough memory to create a new instance of OutOfMemoryException? Luckily this problem has a simple solution: OutOfMemoryException is allocated up front so it's available when it needs to be thrown.&lt;/p&gt;&lt;p&gt;The .NET runtime does first try to create a new OutOfMemoryException instance but if it fails it will fall back to the preallocated instance so there is always an exception available to be thrown. &lt;/p&gt;&lt;p&gt;Some other exceptions are preallocated: StackOverflowException, ExecutionEngineException, and ThreadAbortException.&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9444365" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/kristoffer/archive/tags/Interesting/default.aspx">Interesting</category><category domain="http://blogs.msdn.com/kristoffer/archive/tags/.NET/default.aspx">.NET</category></item></channel></rss>