Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual C++: Difference between Start with/without debugging in Release mode

What is the difference between Start Debugging (F5) and Start without Debugging (CTRL-F5) when the code is compiled in Release mode?

I am seeing that CTRL-F5 is 10x faster than F5 for some C++ code. If I am not wrong, the debugger is attached to the executing process for F5 and it is not for CTRL-F5. Since this is Release mode, the compiled code does not have any debugging information. So, if I do not have any breakpoints, the execution times should be the same across the two, isn't it?!

(Assume that the Release and Debug modes are the typical configurations you get when you create a new Visual C++ project.)

like image 468
Ashwin Nanjappa Avatar asked Jul 29 '10 09:07

Ashwin Nanjappa


People also ask

What is the difference between start debugging and start without debugging?

"Start without debugging" just tells Windows to launch the app as it would normally run. "Start with debugging" starts the VS debugger and has it run the app within the debugger. This really doesn't have much to do with the debug/release build settings.

What is the difference between debug mode and Release mode in Visual Studio?

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.

Whats the difference between debug and Release?

By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled. As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.

What is run without debugging Visual Studio?

Compiles any changed source code, and if the compile is successful, executes your application without invoking the debugger built into the IDE. button (Run Without Debugging).


1 Answers

The problem is that Windows drops in a special Debug Heap, if it detects that your program is running under a Debugger. This appears to happen at the OS level, and is independent of any Debug/Release mode settings for your compilation.

You can work around this 'feature' by setting an environment variable: _NO_DEBUG_HEAP=1

This same issue has been driving me nuts for a while; today I found the following, from whence this post is derived: http://blogs.msdn.com/b/larryosterman/archive/2008/09/03/anatomy-of-a-heisenbug.aspx

like image 52
JBH Avatar answered Nov 02 '22 20:11

JBH