The Debug configuration of your program is compiled with full symbolic debug information which help the debugger figure out where it is in the source code. Is Release mode is faster than Debug mode ? The Release mode enables optimizations and generates without any debug data, so it is fully optimized. .
Visual Studio projects have separate release and debug configurations for your program. You build the debug version for debugging and the release version for the final release distribution. In debug configuration, your program compiles with full symbolic debug information and no optimization.
It's because the optimizer schedules registers completely differently, trying to make code run fast, while the debug compiler tries to preserve values of temporary variables so you can read them from the debugger.
You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.
The most important thing is that in Debug mode there are no optimizations, while in Release mode there are optimizations. This is important because the compiler is very advanced and can do some pretty tricky low-level improving of your code. As a result some lines of your code might get left without any instructions at all, or some might get all mixed up. Step-by-step debugging would be impossible. Also, local variables are often optimized in mysterious ways, so Watches and QuickWatches often don't work because the variable is "optimized away". And there are multitudes of other optimizations too. Try debugging optimized .NET code sometime and you'll see.
Another key difference is that because of this the default Release settings don't bother with generating extensive debug symbol information. That's the .PDB file you might have noticed and it allows the debugger to figure out which assembly instructions corresspond to which line of code, etc.
"Debug" and "Release" are actually just two labels for a whole slew of settings that can affect your build and debugging.
In "Debug" mode you usually have the following:
In "Release" mode optimizations are turned on (though there are multiple options available) and the _DEBUG preprocessor definition is not defined. Usually you will still want to generate the PDB files though, because it's highly useful to be able to "debug" in release mode when things are running faster.
Mostly, debug includes a lot of extra information useful when debugging. In release mode, this is all cut and traded for performance.
If you go through project compile options and compare them, you'd see what are the differences.
Assuming the question is about native/C++ code (it's not entirely clear from the phrasing):
Basically, in Debug all code generation optimizations are off. Some libraries (e.g. STL) default to stricter error checking (e.g. debug iterators). More debugging information is generated (e.g. for "Edit and Continue"). More things are generated in code to catch errors (local variable values are set to an uninitialized pattern, and the debug heap is used).
Also, apparently, Debug mode creates a lot of extra threads to help with debugging. These remain active throughout the life of the process, regardless of whether you attach a debugger or not. See my related question here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With