This post originated from an RSS feed registered with .NET Buzz
by douglas reilly.
Original Post: Another reason not to deploy Debug code...
Feed Title: Doug Reilly's Weblog
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/dreilly/rss.aspx
Feed Description: ASP.NET and More...
In the CLR Internals class today, Jeff Richter gave a great deal of really good information. One thing that I should have figured, but did not really know was about the impact of running Debug code on Garbage Collector performance. Say you have code like this:
public void foo()
{
BigOb big;
big=new BigOb();
System.Console.WriteLine("Big is Really big! {0} ",big.GetSize());
// 1.
LongSlowOperation();
// 2.
}
The C++ programmer in me says that big will be in scope until just after the curly brace below the comment 2. Turns out that in release mode, the big object will be available for garbage collection at the 1 comment (because the framework can tell that it is not referenced again in the code) unless the code is debug code. In that case, the object will be available and not garbage colected as a convenience for you while debugging. In most cases the difference may not be critical, but it just might in some cases.