OSGP.exe 中 0x758cd36f 处的未处理异常:Microsoft C++ 异常:内存位置 0x0028ef70 处的 std::bad_alloc..
我正在尝试在 Visual Studio 中执行以下代码。但是,我一直遇到上述异常。我添加了一个 try catch 来帮助我捕捉错误,但似乎无济于事。我相信问题与输出窗口中的以下内容有关
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).**
这是代码:
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <new>
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int flag = false;
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Node> root;
try
{
root = osgDB::readNodeFile("cessna.osg");
viewer.setSceneData(root.get());
}
catch(bad_alloc)
{
if (flag) cout << "a bad_alloc exception just occured";
}
return viewer.run();
}