views:

241

answers:

1

I know there are several questions asking the same question "Why should I use release mode". The problem I have with the answers is that they simply state, quite strongly, that you should always use release mode when a website is in production.

Why?

I understand that the code is optimised in the assemblies, but to what level? Is it going to optimise well written code? What kind of optimisations does it perform?

Are there any analyses regarding this? Is there anyway I can test the differences between debug and release?

I would really like someone who understands the why of this to at least provide a reference to some definitive reading material, as I have yet to find anything hard enough to satisfy my curiosity on this issue.

+8  A: 

Read this first: http://blogs.msdn.com/tess/archive/2006/04/13/575364.aspx, I just found it as part of answering this question, its a great article.

See this question: http://stackoverflow.com/questions/650652 for some info on general compiler optimizations.

Also, keep in mind that for a Asp.Net web application changing to release mode will compile the assemblies in release mode but for the page compilations you may also need to edit the debug attribute of the compilation element in your web.config.

<compilation defaultLanguage="c#" debug="true">

Web applications do strange things when debug=true is set, for example they do not honor request timeouts because it would interfere with debugging.

Here is a great article from the Gu on the subject: Don’t run production ASP.NET Applications with debug=”true” enabled

Ryan Cook
+1 for the link to Tesses article. That's exactly what I wanted to know. The exact why of the question.The Gu also provided an insight into the caching of WebResource.axd and ScriptResource.axd being cached in instances of release mode deployment.
Khanzor
Also, if you're using any of the ASP.NET AJAX tools, setting debug="false" in the web.config will ensure that the minified versions of the MS scripts are sent to the browser.
Zhaph - Ben Duguid
Nice @Zhaph, good to know!
Khanzor