Click here to Skip to main content
15,888,303 members
Articles / Programming Languages / C++

Troubleshooting Slow C++ Debugging with Visual Studio 2022

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
4 Apr 2023CPOL2 min read 5.4K   4   2
How to troubleshoot slow C++ debugging with VS2022
This blog post shows a way to fix the problem with slow C++ debugging in VS2022.

One day, I was debugging my C++ application on Visual Studio 2022 when the computer suddenly froze. Upon reboot, IntelliSense no longer worked but I quickly fixed it by deleting the .SDF file and restarting Visual Studio. However, subsequently I realized that my program ran slowly, obviously not as slowly as what I experienced when using conditional breakpoints, but the execution speed was clearly not normal.

The slowness only happened when the Visual Studio debugger was attached to the debug build of my app. It did not occur if the debug build started standalone, was attached to another debugger or if a release build was used. Clearly, the issue had got to do with Visual Studio. But why exactly?

After a clean and rebuild did not help, I tried to pull the latest commit of my project from the repository, which also didn’t help. I then tried many things such as disabling Just-In-Time debugging, IntelliTrace, Just My Code, expression evaluation, Edit and Continue with no improvements. It also did not make any sense as these settings had been left as default and did not cause any such issues.

After some searching around, inside the property pages for one of the DLLs used by my app, I adjusted the Debug Information Format to Program Database for Edit And Continue (/ZI) inside C/C++ > Code Generation:

vs3

and also adjust Runtime Library to Multi-threaded Debug DLL (/MDd):

vs1

For some reasons, these settings had been changed to Program Database and Multi-threaded DLL. Finally, inside the Debugging property pages for my C++ Win32 application, I add _NO_DEBUG_HEAP=1 as an additional environment parameter. With this, execution speed improved a bit, but definitely not as fast as before.

vs4

As a last resort, I used Tools > Import and Export Settings, chose to Reset all settings and pick General Development Settings. I could not believe it but the debug speed is now normal, e.g., as fast as it can be. I then reverted the _NO_DEBUG_HEAP setting and realized that the speed was still just as fast, which means setting this value was meaningless.

All in all, I believed some internal Visual Studio settings were corrupted and could only be fixed by resetting all settings. I wasted almost a day on this issue!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Writer
Singapore Singapore
Since 2008, ToughDev has been publishing technical sharing articles on a wide range of topics from software development to electronics design. Our interests include, but are not limited to, Android/iOS programming, VoIP products, embedded design using Arduino/PIC microcontrollers, reverse-engineering, retro-computing, and many others. We also perform product reviews, both on new and vintage products, and share our findings with the community. In addition, our team also develops customized software/hardware solutions highly adapted to suit your needs. Contact us for more information.

Comments and Discussions

 
GeneralMy vote of 5 Pin
germanredcat5-Apr-23 1:59
germanredcat5-Apr-23 1:59 
QuestionVS Nightmare Pin
IssamTP4-Apr-23 23:07
IssamTP4-Apr-23 23:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.