Visual C++:在发布模式下开始调试和不调试之间的区别 [英] Visual C++: Difference between Start with/without debugging in Release mode

查看:28
本文介绍了Visual C++:在发布模式下开始调试和不调试之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开始调试(F5)不调试开始(CTRL-F5)有什么区别?kbd>) 在发布模式下编译代码时?

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

我发现对于某些 C++ 代码,CTRL-F5F5 快 10 倍.如果我没记错的话,调试器附加到 F5 的执行进程,而不是 CTRL-F5.由于这是Release模式,编译后的代码没有任何调试信息.所以,如果我没有任何断点,两者的执行时间应该是一样的,不是吗?!

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?!

(假设发布和调试模式是您在创建新的 Visual C++ 项目时获得的典型配置.)

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

推荐答案

问题是,如果 Windows 检测到您的程序正在调试器下运行,它就会进入一个特殊的调试堆.这似乎发生在操作系统级别,并且与编译的任何调试/发布模式设置无关.

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.

您可以通过设置环境变量来解决此功能":_NO_DEBUG_HEAP=1

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

同样的问题已经让我发疯了一段时间;今天我发现了以下内容,这篇文章的来源:http://blogs.msdn.com/b/larryosterman/archive/2008/09/03/anatomy-of-a-heisenbug.aspx

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

这篇关于Visual C++:在发布模式下开始调试和不调试之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆