4

I build a C++ application that does some number crunching. I'm running in Visual Studio 2008 PRO SP1, in release mode, Windows 7 64 bit. If I run it inside the IDE, the application takes 4 minutes, if I run the same executable from windows explorer it takes 6 seconds! I have no clue. I have checked that this does not depend on the processor and operating system. I don't think I have strange VS plugins that are doing something in the background.

Any hints? Thank you in advance!

Marco

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Marco Fiocco
  • 352
  • 2
  • 15

2 Answers2

11

Presumably, the slow down is caused by the debugger being attached when you are starting the application in Visual Studio. This is the case even when you've built the program in "Release" mode.

To confirm that this is indeed the source of your problem, try running your application without the debugger, using the "Start Without Debugging" command or Ctrl+F5.

   Start Without Debugging

It's worth nothing that in C++ specifically, when you start without debugging, your program won't use the Windows debug heap. With the debugger attached, it will.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • This works for me, I wasn't aware that the debugger was still running even in release mode. Thanks! – Marco Fiocco Jan 06 '11 at 16:05
  • 1
    Check the Output window to see what's going on. Do not use exceptions for control flow. – Hans Passant Jan 06 '11 at 16:08
  • @Marco: Indeed. The idea is that you can still hit breakpoints, etc. even when compiled in Release mode. Glad to hear it fixed your problem. Of course, I wouldn't worry too much about it—your app being a lot faster running *outside* of the debugger is far and away preferable over the reverse! – Cody Gray - on strike Jan 06 '11 at 16:08
  • @Marco Fiocco -- of course, if you started debugger it will be running, including release mode, how else would you debug release build? – Gene Bushuyev Jan 06 '11 at 16:08
  • @gene-bushuyev It seems natural to assume that you can only debug in debug mode! – hypehuman Nov 30 '15 at 23:40
0

As Cody mentioned, one option is to simply not debug. But if you want to speed up your debugging sessions, here are a few things I've found can make a huge difference:

  1. Remove debugging print statements that are no longer necessary. If you see your log filling up with text, that is likely slowing you down significantly.
  2. Remove breakpoints (Ctrl+Shift+F5). A couple times I've noticed a huge drop in performance, and it turned out to be due to a breakpoint with a condition that was never met.
hypehuman
  • 1,290
  • 2
  • 18
  • 37