16

Duplicate of: Debug vs. release in .NET

Why are there 'Debug' and 'Release' modes on build in .NET applications?

What is the major technical difference between them?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dhanapal
  • 14,239
  • 35
  • 115
  • 142

4 Answers4

13

Differences:

  • Debug inserts NOPs (No-operation CPU instructions) between useful CIL code in order to allow debugger attachment
  • Debug does not allow various optimizations:
    • Inlining (placing a method's code in place of a call to it in order to reduce call overhead)
    • Loop unrolling (replacing a loop code - such as a for - with the repeated code to eliminate loop overhead (loop variable maintenance))

And many others. Release is sensibly faster, but it offers no real debug support. For debugging there is... the debug mode :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166
7

A short answer is that code built in 'Release' mode will be optimised for speed or size and also will have all the information used for debugging removed

Chris B
  • 5,311
  • 11
  • 45
  • 57
0

The main difference as I understand it is that in Debug Mode the whole symbol information which is used by the debugger is stored along with the program, so that if a developer wants to debug the application before releasing he/she may do so, by attaching to any debugger.

You might've noticed the .pdb files in the debug folder. Also the size of the executable is fairly larger. However in Release mode, the debugger symbol information is omitted assuming that the end user is going to use the application so he must not be provided with the application symbols.

You can think of the symbols as the information provided to the debugger to understand what local variables, what functions, where breakpoints are set and all sorts of information so that it can precisely tell you what part of code is being executed currently.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
0

Yeah right, you can even debug in release mode [:)]. There are elaborate processes to do it.

However, the release build is optimized for speed and performance. Also the Microsoft End user licence agreement states that you cannot deploy your debug files on a client system.

http://www.codeproject.com/KB/debug/releasemode.aspx

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sidhartha Shenoy
  • 179
  • 1
  • 13