C++ bad_alloc at memory location Ausnahme

Nicht behandelte Ausnahme bei 0x758cd36f in OSGP.exe: Microsoft C++ - Ausnahme: std::bad_alloc at memory location 0x0028ef70..

Ich versuche, führen Sie den folgenden code in Visual Studio. Allerdings habe ich immer wieder mit der Ausnahme oben. Ich habe ein try catch um Hilfe mir fangen die Fehler aber ohne Erfolg wie es scheint. Ich glaube das problem bezieht sich auf die folgenden aus dem Ausgabe-Fenster

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).**

Hier der code:

#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"); zurückgeben kann nullptr wenn es nicht gelingt, die Datei zu öffnen. Zur info Zuordnung eines bool zu einem int flag, das ist schon mal nicht wirklich verwendet wird, ist auch ein bisschen dumm 😉
Die meisten der Ausgang ist nur der debugger sagen Sie es nicht finden können, die Programm-Datenbank (symbol) - Datei.
Schalten Ausnahme Haltepunkte in Debug->Exceptions...->C++ Exceptions so dass Sie aufhören, wenn die bad_alloc geworfen wird.

InformationsquelleAutor user272671 | 2012-06-07

Schreibe einen Kommentar