C#/VB.NET Configuration - Do you know not to use debug compilation in production applications?

Last updated by Brady Stroud [SSW] about 2 months ago.See history

Debug compilation considerably increases memory footprint since debug symbols are required to be loaded.

Additionally it will hit the performance because that will include the optional debug and trace statements in the output IL code.

In debug mode the compiler emits debug symbols for all variables and compiles the code as is. In release mode some optimizations are included:

  • unused variables do not get compiled at all
  • some loop variables are taken out of the loop by the compiler if they are proven to be invariants
  • code written under #debug directive is not included etc.

The rest is up to the JIT.

As per: C# debug vs release performance.

debug bad
Figure: Bad Example

debug good
Figure: Good Example

We have a program called SSW Code Auditor to check for this rule.

We open source. Powered by GitHub