title: C++ program takes a very long time on function return
body: <p>I have a function that was written by someone else and I have determined that it can sometimes take a very long amount of time to step out of the function after it has fully executed every statement within the function block.  If I recall correctly, the only thing that happens during this time is all destructors on the stack (local) objects are called and then the function returns as the stack pointer is moved.  I would like to post the function, but it's a bit complicated and the intellectual property of someone else.  However, only standard STL containers are declared on the stack.  The containers are </p>
  
  <pre><code>set&lt;unsigned int&gt; 
  unordered_map&lt;unsigned_int, vector&lt;unsigned int&gt;&gt;
  vector&lt;pair&lt;set&lt;unsigned int&gt;,set&lt;unsigned int&gt; &gt; &gt;
  vector&lt;pair&lt;set&lt;unsigned int&gt;,int&gt; &gt;
  set&lt;unsigned int&gt;
  several unsigned ints
  unordered_map&lt;unsigned int, unordered_map&lt;unsigned int, bool&gt; &gt; 
  set&lt;unsigned int&gt;
  set&lt;unsigned int&gt;
  </code></pre>
  
  <p>Does anyone know why this might be happening?  I'm thinking that the time might be consumed by destructor calls on the locally-declared STL objects.  Has anyone seen this happen before?  Anywhere else I should look?</p>