use*_*671 3 c++ opengl openscenegraph visual-studio-2010
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).**
Run Code Online (Sandbox Code Playgroud)
这是代码:
#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();
}
Run Code Online (Sandbox Code Playgroud)
当程序没有足够的内存来完成请求的操作时,通常会抛出std :: bad_alloc.
可能的问题:
但是不可能用所提供的信息说出来.