The initial phase of my program loads in significant amounts of data into STL containers. I found that it was taking several minutes before I could reach the real meat of my program.
After some searching, I found that I could set _NO_DEBUG_HEAP==1 within my VS2012 Configuration Properties->Debugging->Environment variable...turning off utilization of the windows debug heap. This gave me a 10x improvement in debugging speed. I have not yet found any description what what debugging functionality I lose by doing so.
In summary: what checks were completed and what debug info was being generated by using the windows debug heap?
Thank you.
The debug heap provides powerful tools to solve memory allocation problems of this kind. The Debug versions of the heap functions call the standard or base versions used in Release builds.
It is not the Debug CRT heap. It's actually quite nice, but can be slow if you're allocating/freeing a lot of memory. This is something OpenSG's 3ds-importer does, and the difference is a 3-5 times slowdown when debugging.
Usually I haven't had performance problems, but rather Heisenbugs that disappear when debugging (since allocated memory is 0xbaadfood instead of pseudo-random), which I've solved by attaching the debugger afterwards. Those are not many, so it's been ok to do that at times.
Every memory block in the debug heap is assigned to one of five allocation types. These types are tracked and reported differently for purposes of leak detection and state reporting. You can specify a block's type by allocating it using a direct call to one of the debug heap allocation functions such as _malloc_dbg.
The debug heap impacts performance in two ways:
First, it adds checks to the heap integrity during heap operations. I haven't found details on these checks, but one assumes that on each allocation or free, it involves verifying the integrity of the data structures used to manage the heap.
Second, it disables the low-fragmentation heap (LFH) option. In a release build, you get LFH by default. In a debug build, you don't--unless you use the _NO_DEBUG_HEAP. This isn't necessarily a speed penalty, but it might be.
There are clues in the documentation for HeapSetInformation
.
Note that the C and C++ runtime libraries provide memory management built on top of the system heap APIs, and they also have debug and non-debug modes that can affect performance. There is more detailed documentation about what the debug CRT does. You might check and see if turning off the CRT debugging is enough to get you a significant boost in performance without messing with the debug mode of the process heap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With