在OSGP.exe在0x758cd36f 未處理的異常:微軟C++異常:性病:: bad_alloc的內存位置0x0028ef70 ..C++ 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();
}
'osgDB :: readNodeFile(「cessna.osg」);'如果無法打開文件,可以返回nullptr。 FYI給'int'標誌分配一個以前沒有使用過的'int'標誌也是有點愚蠢;-) – AJG85
大多數輸出只是調試器告訴你它找不到程序數據庫(符號)文件。 –
打開'Debug-> Exceptions ...-> C++ Exceptions'中的異常斷點,以便在引發bad_alloc時停止。 – molbdnilo