title: c++ bad_alloc exception not catched
body: <p>I have following code to allocate a huge amount of data and if it is more than there is memory available (here it is 32GB) it should throw an exception. Using:</p>
  
  <pre><code>bool MyObject::init()
  {    
      char* emergency_memory = new char[32768];
      try
      {
          std::vector&lt;std::vector&lt;MyData&gt; &gt; data_list;
          std::vector&lt;MyData&gt; data;
          data.resize(1000);
  
          for(size_t i=0; i&lt;1000; i++)
          {
             data_list.push_back(data);
             data_list.push_back(data);
          }       
      }
      catch (const std::bad_alloc&amp; e)
      {
          delete[] emergency_memory;        
          std::cout &lt;&lt; "Data Allocation failed:" &lt;&lt; e.what() &lt;&lt; std::endl;
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>The exception is never caught. The application just terminates, or crashes the operating system. </p>
  
  <p>What did I do wrong?</p>