简体   繁体   English

在MSVC中混合调试和发布?

[英]Mixing debug and release in MSVC?

I got a program that has a quite simple 'load up' function that takes about 30 seconds (3M triangles that goes into std containers). 我有一个程序,该程序具有非常简单的“加载”功能,该功能大约需要30秒(将3M三角形插入std容器)。 It works perfectly well. 效果很好。

The rest doesn't always (it is not finished) so I debug a lot I make a lot of changes and so on which means restarting quite often. 其余的并不总是(未完成),因此我进行了很多调试,进行了很多更改,依此类推,这意味着非常频繁地重新启动。

Is there any secret technique to compile the loader in release (which speeds up everything enormously) and leaving the rest as debug? 是否有任何秘密技术可以在发行版中编译加载程序(这极大地加快了一切速度),而将其余部分留作调试?

ps. PS。 I use MSVC 2005 我使用MSVC 2005

Debug builds tend to be very slow on Visual C++. 在Visual C ++上,调试版本往往很慢。 There are a few reasons for this: 这有几个原因:

  • the most obvious is that the code is not optimized 最明显的是代码没有优化
  • the memory allocation functions in the debug CRT library perform additional checks to detect heap corruption and other issues, so they are slower. 调试CRT库中的内存分配功能会执行其他检查以检测堆损坏和其他问题,因此速度较慢。
  • many STL functions perform additional validations and assertions on debug builds, which make use of STL containers very slow 许多STL函数在调试版本上执行附加的验证和断言,这使STL容器的使用非常慢

I've had success debugging apps that make heavy use of memory and STL using the following method: 我已经成功调试了使用以下方法大量使用内存和STL的应用程序:

  • use the release build for debugging (yes, this works fine!). 使用发行版进行调试(是的,这很好!)。
  • configure your release builds to include debugging symbols, this should make the compiler write the .pdb file that the debugger uses 配置发布版本以包含调试符号,这应使编译器编写调试器使用的.pdb文件
  • only for the files you intend to debug, set the compiler to no optimizations. 仅针对要调试的文件,将编译器设置为无优化。

Note that the above works great to debug problems in your own logic, but it may not be the best idea if you are debugging memory corruption or other problems, since you are eliminating all the extra debug code that the CRT provides for these types of issues. 请注意,上面的方法对于调试您自己的逻辑中的问题非常有用,但是如果您要调试内存损坏或其他问题,则并不是最好的主意,因为您将消除CRT为这些类型的问题提供的所有其他调试代码。 。

I hope this helps! 我希望这有帮助!

Mixing debug and release builds tends to go horribly wrong. 混合使用调试版本和发行版本往往会出错。

But there's no reason why you shouldn't turn on optimisation for some selected source files even in a debug build - and the optimisation should give you the performance improvements. 但是,没有理由为什么即使在调试版本中也不应为某些选定的源文件打开优化功能-并且该优化功能可以提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM