Of course, producing the second view (without F5) was a bit harder, so I set a breakpoint using _asm int 3 ( DebugBreak() also would work), then I got debugger attached so I could also pause at random. There were lots of allocations, so I usually entered some interesting code. To prepare the above images, I run the app using F5 and I paused at random position. So by running using F5, we get ~3.7 slower memory allocations! Release mode, running exe: 1313 milliseconds Let’s learn from the situation! What is this debug heap? Is it really useful? Can we live without it? Example As in our situation: debugger was changing the performance of my application so I was not able to find a real hot spot… Those kind of bugs have even their name Heisenbug, those are bugs that disappear (or are altered) by tools that are used to track the problem. When I disabled the additional heap checking (or when I simply run my application without debugger attached), the real bottleneck appeared in a completely different place. When running using F5, the main bottleneck seemed to be happening in that UI code. My code used win32 UI and thus every list addition, control creation was double checked by this special heap. What was wrong with the assumption? As it appeared when I was starting the app with F5, even in release mode Visual Studio is attaching a special debug heap! The whole application runs slower, because every system memory allocation gets additional integrity checks. What was my astonishment when I noticed it was a wrong idea! My release-debug session pointed to a completely different place in the code… Story Continuation The app used OutputDebugString so I needed to run the debugging (F5) in order to be able to see logs in the output window (I know I know, I could use DebugView as well…)īut, my main assumption was that when I run F5 in release mode, only a little performance hit would occur. I prepared the release version of the app and I added some profiling code. I needed to track what module was eating most of the time in one specific scenario. Some time ago, I was tracing a perf problem (UI code + some custom logic).
0 Comments
Leave a Reply. |