title: Weird behaviour of C++ destructors
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main()
  {
      vector&lt; vector&lt;int&gt; &gt; dp(50000, vector&lt;int&gt;(4, -1));
      cout &lt;&lt; dp.size();
  }
  </code></pre>
  
  <p>This tiny program takes a split second to execute when simply run from the command line. But when run in a debugger, it takes over 8 seconds. Pausing the debugger reveals that it is in the middle of destroying all those vectors. WTF?</p>
  
  <p>Note - Visual Studio 2008 SP1, Core 2 Duo 6700 CPU with 2GB of RAM.</p>
  
  <p><strong>Added:</strong> To clarify, no, I'm not confusing Debug and Release builds. These results are on one and the same .exe, without even any recompiling inbetween. In fact, switching between Debug and Release builds changes nothing.</p>