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.
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: At what level C# compiler or JIT optimize the application code? 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