title: Disable iterator debugging in VS2010
body: <p>I've been wondering why is application I'm now fixing running so damn slow in debug mode compared to release. The ratio can be up to 600 times, where 500ms operation takes 5 minutes.</p>
  
  <p>I already gave up on any profilers available for windows, they all have some property that makes them suck, be it crashing, not loading symbols... So I decided to profile <em>statistically</em>. I randomly paused the execution using the pause button. This code fragment turned out to appear most of the time when I paused:</p>
  
  <pre><code>#if _ITERATOR_DEBUG_LEVEL == 2
           if (_Myproxy != 0)
                  {      // adopted, remove self from list
                  _Iterator_base12 **_Pnext = &amp;_Myproxy-&gt;_Myfirstiter;
                  while (*_Pnext != 0 &amp;&amp; *_Pnext != this)
                         _Pnext = &amp;(*_Pnext)-&gt;_Mynextiter;
  
                  if (*_Pnext == 0)
                         _DEBUG_ERROR("ITERATOR LIST CORRUPTED!");
                  *_Pnext = _Mynextiter;
                  _Myproxy = 0;
                  }
  #endif /* _ITERATOR_DEBUG_LEVEL == 2 */
  </code></pre>
  
  <p>This is in a Visual Studio file. I tracked how <code>_ITERATOR_DEBUG_LEVEL</code> is defined and unveiled that setting <code>_HAS_ITERATOR_DEBUGGING</code> to zero would prevent <code>_ITERATOR_DEBUG_LEVEL</code> from being <code>2</code>.</p>
  
  <p>Now I would post the code where the <code>_HAS_ITERATOR_DEBUGGING</code> is being set (<em>edit: it's file <code>Microsoft Visual Studio 10.0\VC\include\yvals.h</code></em>), but when I go to Project properties<code>-&gt;</code>C/C++<code>-&gt;</code>Preprocesor and add <code>_HAS_ITERATOR_DEBUGGING=0</code>, the Visual Studio goes into endless loop and I have to kill the process <code>devenv.exe</code>.</p>
  
  <p>Fortunately, I had no unsaved changes (except breakpoints). Why did this happen and how to go around it? Many features can't be tested in debug mode, because it would probably take several years.</p>
  
  <hr>
  
  <p>VS Version info:</p>
  
  <pre><code>Microsoft Visual Studio 2010
  Version 10.0.40219.1 SP1Rel
  </code></pre>