Slow debugging in Visual Studio 2015 -- can't turn off page heap?

527 views Asked by At

I am running Visual Studio 2015 and never had issues debugging before. However, lately debugging is very slow. I also started getting heap debug errors saying "Heap Corruption Detected" from the Microsoft Visual C++ Runtime Library. I will fix the errors where the application is writing to memory after the end of the heap buffer, but the debugger is extremely slow even when I am not running the code that throws those errors. I think there is some heap-checking setting on, and I want to turn it off.

The debug output window has two lines at the top, each saying Page heap: pid 0x530: page heap enabled with flags 0x2. I believe this is the source of the problem, or at least related. I cannot turn off page heap. I tried in the gflags GUI (nothing was checked, but I tried checking and un-checking), and I tried on the command line. Restarted VS, restarted my computer, uninstalled and reinstalled VS... nothing works.

When I run the release configuration in VS, it is still slow and I still see the page heap messages at the top of the output window. However, instead of getting the heap debug error messages, the application just freezes. But the page heap messages make me think this is an issue outside of VS, not something to do with my debug configuration.

Edit: I am using wxWidgets 3.1 and I noticed my program runs slowest during wxWidgets-related events, like opening a file or outputting many lines to a textCtrl. Not sure if this is relevant or not.

1

There are 1 answers

0
lizcoder On

I believe I solved the problem. The GlobalFlag flag was indeed set. I used Process Monitor to see what keys were being accessed from the registry, and that confirmed my suspicion that GFlags was being used for my particular image file. I have no idea why neither the command line nor the GUI versions of gflags let me see or edit the flags.

Anyway, I went to Registry Editor (regedit) and navigated to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ImageFileName. There, GlobalFlag was set to 0x20000000, which this page explains is the flag for Page Heap. So, following the directions from this page, I set the GlobalFlag to -FFFFFFFF and it worked! I am able to debug again normally.

Edit: Not quite. The debugger is much faster now and no longer lags. However, I still am getting the "Heap debug error" occasionally.