0

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.

lizcoder
  • 43
  • 6
  • "I am running Visual Studio 2015" - consider upgrading to the latest 2017. – Jesper Juhl Jul 23 '18 at 20:04
  • How slow is slow? Page heap shouldn't be that much slower. Maybe you are just running out of memory? – user7860670 Jul 23 '18 at 20:13
  • @VTT slow enough to cause timing issues while communicating with another application. – lizcoder Jul 23 '18 at 20:38
  • "Page heap: pid 0x530: page heap enabled with flags 0x2". Yup, you don't want that. You ran gflags.exe to turn that on, sometimes useful to find heap corruption bugs. Only sometimes, appverifier is the better tool. But you forgot to turn it off, run it again. – Hans Passant Jul 23 '18 at 21:48
  • I attempted to turn it off, see the original post. – lizcoder Jul 23 '18 at 22:00
  • Run gflags /p to get a listing of programs with flags turned on. – Hans Passant Jul 23 '18 at 22:03
  • Nothing is shown. The GUI opens for a split second and nothing is listed on the command prompt. When I open the GUI separately nothing is checked. – lizcoder Jul 23 '18 at 22:10
  • @lizcoder, try to turn off AV/FW (temporarily, for test purposes). – Igor Jul 25 '18 at 15:03
  • @lizcoder, also try to create a simple C++ project with Hello World. Can you run it with the debugger on the normal speed? – Igor Jul 25 '18 at 15:06

1 Answers1

0

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.

lizcoder
  • 43
  • 6