title: C++ bad_alloc at memory location Exception
body: <blockquote>
    <p><strong>Unhandled exception at 0x758cd36f in OSGP.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028ef70..</strong></p>
  </blockquote>
  
  <p>I am trying to execute the code below in Visual Studio. However, i keep running into the exception above. I added a try catch to aid me in catching the error but to no avail  it seems. I believe the problem is related to the following from the output window</p>
  
  <pre><code>First-chance exception at 0x758cd36f in OSGP.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0019f2f4..
  First-chance exception at 0x758cd36f in OSGP.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0019ec84..
  First-chance exception at 0x758cd36f in OSGP.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
  The thread 'Win32 Thread' (0x16dc) has exited with code 0 (0x0).
  The program '[448] OSGP.exe: Native' has exited with code 0 (0x0).**
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;osgDB/ReadFile&gt;
  #include &lt;osgViewer/Viewer&gt;
  #include &lt;new&gt;
  
  #include "stdafx.h"
  
  using namespace std;
  
  int _tmain(int argc, _TCHAR* argv[])
  { 
      int flag = false;
      osgViewer::Viewer viewer;
       osg::ref_ptr&lt;osg::Node&gt; root;
      try
      { 
          root = osgDB::readNodeFile("cessna.osg");
          viewer.setSceneData(root.get()); 
      }
      catch(bad_alloc)
      { 
          if (flag) cout &lt;&lt; "a bad_alloc exception just occured"; 
      }
      return viewer.run(); 
  }
  </code></pre>