Changeset 87


Ignore:
Timestamp:
Jul 28, 2010, 5:13:22 PM (14 years ago)
Author:
Torben Dannhauer
Message:

Introductes VS 2008 Memory Leak Debugging.
Todo: Compile on Linux and compare with Valgrind, VS 2008 seems to be awkward in leak debugging

Location:
osgVisual
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/include/core/leakDetection.h

    r86 r87  
    2121
    2222#ifdef _DEBUG
    23         #ifndef DBG_NEW
    24                 #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
    25                 #define new DBG_NEW
     23        #ifdef WIN32
     24                #ifndef DBG_NEW
     25                        #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
     26                        #define new DBG_NEW
     27                #endif
    2628        #endif
    2729#endif
  • osgVisual/include/core/visual_core.h

    r67 r87  
    160160
    161161        osg::ref_ptr<osgGA::NodeTrackerManipulator> nt;
     162
     163        osg::ref_ptr<visual_debug_hud> hud;
    162164};
    163165
  • osgVisual/include/sky_Silverlining/skySilverLining_ProjectionMatrixCallback.h

    r32 r87  
    5555        atmosphere(atm), camera(cam), csn(csn_), skyDrawable(0), minFar(90000), maxNear(2)
    5656    {
     57                #include <leakDetection.h>
     58
    5759        stockCullVisitor = osgUtil::CullVisitor::create();
    5860                //stockCullVisitor->setNearFarRatio( 0.00005 );
  • osgVisual/src/cluster/dataIO_clusterENet.cpp

    r84 r87  
    2222{
    2323        OSG_NOTIFY( osg::ALWAYS ) << "clusterENet constructed" << std::endl;
     24        #include <leakDetection.h>
     25
    2426        serverToConnect = "unknown";
    2527        hardSync = false;       // integrate into init()
  • osgVisual/src/cluster/dataIO_clusterENet_implementation.cpp

    r77 r87  
    2525{
    2626        std::cout << "Instantiated server class# "<< activeENetInstances << std::endl;
     27        #include <leakDetection.h>
    2728        enetInitialized = false;
    2829        host = NULL;
  • osgVisual/src/core/osgVisual.cpp

    r86 r87  
    1515*/
    1616
    17 // Declare this in header.
     17const unsigned int MAX_NUM_EVENTS = 10;
     18
     19#ifdef _DEBUG
     20        #ifdef WIN32
     21                // Declare this in header.
     22                #define _CRTDBG_MAP_ALLOC
     23                #include <stdlib.h>
     24                #include <crtdbg.h>
     25        #endif
     26#endif
     27
    1828//#include <windows.h>
    19 #define _CRTDBG_MAP_ALLOC
    20 #include <crtdbg.h>
    2129
    2230#include <osg/ArgumentParser>
     
    2634#include <visual_core.h>
    2735
    28 const unsigned int MAX_NUM_EVENTS = 10;
     36
    2937
    3038
     
    3341       
    3442#ifdef _DEBUG
    35         #include <leakDetection.h>      // ugly but must be included inside the class
     43        #ifdef WIN32
     44                #include <leakDetection.h>      // ugly but must be included inside the class
    3645
    37     int tmp_flag;
     46                int tmp_flag;
    3847
    39     HANDLE log_file = CreateFile("mem_log.txt", GENERIC_WRITE,FILE_SHARE_WRITE,
    40         NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
     48                HANDLE log_file = CreateFile("mem_log.txt", GENERIC_WRITE,FILE_SHARE_WRITE,
     49                        NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    4150
    42     _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
    43         _CRTDBG_MODE_DEBUG);
    44     _CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
    45     _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
    46         _CRTDBG_MODE_DEBUG);
     51                _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
     52                        _CRTDBG_MODE_DEBUG);
     53                _CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
     54                _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
     55                        _CRTDBG_MODE_DEBUG);
    4756
    48     // output to the file if not under VS
    49     _CrtSetReportFile(_CRT_ASSERT, log_file);
    50     _CrtSetReportFile(_CRT_WARN, log_file);
    51     _CrtSetReportFile(_CRT_ERROR, log_file);
     57                // output to the file if not under VS
     58                _CrtSetReportFile(_CRT_ASSERT, log_file);
     59                _CrtSetReportFile(_CRT_WARN, log_file);
     60                _CrtSetReportFile(_CRT_ERROR, log_file);
    5261
    53     tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    54     tmp_flag |= _CRTDBG_ALLOC_MEM_DF;
    55     tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
    56     tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
     62                tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
     63                tmp_flag |= _CRTDBG_ALLOC_MEM_DF;
     64                tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
     65                tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
    5766
    58     _CrtSetDbgFlag(tmp_flag);
     67                _CrtSetDbgFlag(tmp_flag);
     68        #endif
    5969#endif
    6070
     
    6878    core->initialize();
    6979
     80        // Shut osgVisual down
     81        core->shutdown();
     82
    7083        // Set Pointer to null to destroy the objects before this function ends - otherwise memory leaks wil be detected.
    7184        core = NULL;
  • osgVisual/src/core/visual_core.cpp

    r86 r87  
    2828visual_core::~visual_core(void)
    2929{
    30         // shut osgVisual down
    31         shutdown();
    32 
    3330        OSG_NOTIFY( osg::ALWAYS ) << "visual_core destroyed." << std::endl;
    34 
    3531}
    3632
     
    4945
    5046        // Setup coordinate system node
    51         rootNode = new osg::CoordinateSystemNode;
     47        rootNode = new osg::CoordinateSystemNode;       // todo memleakf
    5248        rootNode->setEllipsoidModel(new osg::EllipsoidModel());
    5349
    5450        // Test memory leak (todo)
    55         double* test = new double[1000];
     51        //double* test = new double[1000];
    5652
    5753        #ifdef USE_SPACENAVIGATOR
     
    130126        OSG_NOTIFY( osg::ALWAYS ) << "Shutdown visual_core..." << std::endl;
    131127
     128        // Shutdown Dbug HUD
     129        if(hud.valid())
     130                hud->shutdown();
    132131        // Unset scene data
    133132        viewer->setSceneData( NULL );
     
    144143                distortion->shutdown();
    145144#endif
     145
     146        // Shutdown data
     147        rootNode = NULL;
    146148
    147149        // Shutdown dataIO
     
    295297        //testObj->addUpdater( new object_updater(testObj) );
    296298
    297         osg::ref_ptr<visual_object> testObj2 = new visual_object( rootNode, "cessna" );
     299        osg::ref_ptr<visual_object> testObj2 = new visual_object( rootNode, "cessna" ); // todo memleak
    298300        //testObj2->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 );
    299301        testObj2->setNewPosition( osg::DegreesToRadians(50.8123), osg::DegreesToRadians(8.94088), 600 );
    300302        testObj2->loadGeometry( "../models/cessna.osg" );
    301         testObj2->addUpdater( new object_updater(testObj2) );
    302 
    303         osg::ref_ptr<visual_object> testObj3 = new visual_object( rootNode, "SAENGER1" );
     303        testObj2->addUpdater( new object_updater(testObj2) );   // todo memleak
     304
     305        osg::ref_ptr<visual_object> testObj3 = new visual_object( rootNode, "SAENGER1" );       // todo memleak
    304306        testObj3->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 );
    305307        testObj3->loadGeometry( "../models/saenger1.flt" );
    306         testObj3->addUpdater( new object_updater(testObj3) );
    307        
    308 
    309         osg::ref_ptr<visual_object> testObj4 = new visual_object( rootNode, "SAENGER2" );
     308        testObj3->addUpdater( new object_updater(testObj3) );   // todo memleak
     309       
     310
     311        osg::ref_ptr<visual_object> testObj4 = new visual_object( rootNode, "SAENGER2" );       // todo memleak
    310312        testObj4->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 650 );
    311313        testObj4->loadGeometry( "../models/saenger2.flt" );
    312         testObj4->addUpdater( new object_updater(testObj4) );
     314        testObj4->addUpdater( new object_updater(testObj4) );   // todo memleak
    313315        testObj4->addLabel("testLabel", "LabelTest!!\nnächste Zeile :)",osg::Vec4(1.0f,0.25f,1.0f,1.0f));
    314316
    315         osg::ref_ptr<visual_object> testObj5 = new visual_object( rootNode, "SAENGER" );
     317        osg::ref_ptr<visual_object> testObj5 = new visual_object( rootNode, "SAENGER" );        // todo memleak
    316318        testObj5->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 550 );
    317319        testObj5->loadGeometry( "../models/saengerCombine.flt" );
    318320        //testObj5->setScale( 2 );
    319         testObj5->addUpdater( new object_updater(testObj5) );
     321        testObj5->addUpdater( new object_updater(testObj5) );   // todo memleak
    320322
    321323#ifdef USE_SPACENAVIGATOR
     
    359361        visual_draw2D::getInstance()->init( rootNode, viewer );
    360362        //osg::ref_ptr<visual_hud> hud = new visual_hud();
    361         osg::ref_ptr<visual_debug_hud> hud = new visual_debug_hud();
     363        hud = new visual_debug_hud();
    362364        hud->init( viewer, rootNode );
    363365       
  • osgVisual/src/dataIO/visual_dataIO.cpp

    r84 r87  
    2222{
    2323        OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO constructed" << std::endl;
    24 
     24        #include <leakDetection.h>
    2525        initialized = false;
    2626}
  • osgVisual/src/distortion/visual_distortion.cpp

    r70 r87  
    2222{
    2323        OSG_NOTIFY (osg::ALWAYS ) << "visual_distortion instantiated." << std::endl;
     24        #include <leakDetection.h>
    2425
    2526        initialized = false;
  • osgVisual/src/draw2D/visual_debug_hud.cpp

    r31 r87  
    2121visual_debug_hud::visual_debug_hud(void)
    2222{
    23 
     23        #include <leakDetection.h>
    2424}
    2525
     
    5151        if (isInitialized)
    5252        {       
     53                // Remove Draw Content
     54                visual_draw2D::getInstance()->removeDrawContent("HUD");
     55
    5356                // Remove updatecallback
    54                 this->removeUpdateCallback( updateCallback );
     57                this->removeEventCallback( updateCallback );
    5558                updateCallback = NULL;
    5659        }
  • osgVisual/src/draw2D/visual_draw2D.cpp

    r31 r87  
    2222{
    2323        OSG_NOTIFY( osg::ALWAYS ) << "visual_draw2D constructed" << std::endl;
     24        #include <leakDetection.h>
    2425        initialized = false;
    2526}
  • osgVisual/src/draw2D/visual_hud.cpp

    r31 r87  
    2121visual_hud::visual_hud(void)
    2222{
     23        #include <leakDetection.h>
    2324}
    2425
  • osgVisual/src/draw3D/visual_draw3D.cpp

    r31 r87  
    2121visual_draw3D::visual_draw3D(void)
    2222{
     23        #include <leakDetection.h>
    2324}
    2425
  • osgVisual/src/extLink/dataIO_extLinkVCL.cpp

    r57 r87  
    2424{
    2525        OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL constructed" << std::endl;
     26        #include <leakDetection.h>
    2627}
    2728
  • osgVisual/src/extLink/manip_extLink.cpp

    r31 r87  
    2424extLinkManipulator::extLinkManipulator()
    2525{
     26        #include <leakDetection.h>
    2627}
    2728
  • osgVisual/src/manip_ObjectMounted/manip_objectMounted.cpp

    r31 r87  
    2525objectMountedManipulator::objectMountedManipulator()
    2626{
     27        #include <leakDetection.h>
    2728}
    2829
  • osgVisual/src/manip_Spacemouse/manip_freeSpaceMouse.cpp

    r31 r87  
    2525FreeManipulator::FreeManipulator(SpaceMouse* spacemouse) : _spaceMouse(spacemouse)
    2626{
     27        #include <leakDetection.h>
    2728}
    2829
  • osgVisual/src/manip_Spacemouse/manip_nodeTrackerSpaceMouse.cpp

    r31 r87  
    2525NodeTrackerSpaceMouse::NodeTrackerSpaceMouse(SpaceMouse* spacemouse) : _spaceMouse(spacemouse)
    2626{
     27        #include <leakDetection.h>
    2728    _trackerMode = NODE_CENTER_AND_ROTATION;
    2829    _rotationMode = TRACKBALL;
  • osgVisual/src/manip_Spacemouse/manip_spaceMouse.cpp

    r55 r87  
    168168SpaceMouse::SpaceMouse() : _spaceMouseImpl(new SpaceMouseImpl)
    169169{
     170        #include <leakDetection.h>
    170171}
    171172
  • osgVisual/src/object/object_updater.cpp

    r31 r87  
    2121object_updater::object_updater(osgVisual::visual_object* object_ )
    2222{
     23        #include <leakDetection.h>
    2324}
    2425
  • osgVisual/src/object/visual_object.cpp

    r36 r87  
    2121visual_object::visual_object( osg::CoordinateSystemNode* sceneRoot_, std::string nodeName_)
    2222{
     23        #include <leakDetection.h>
     24
    2325        // Add this node to Scenegraph
    2426        sceneRoot_->addChild( this );
  • osgVisual/src/sky_Silverlining/skySilverLining_cloudsDrawable.cpp

    r31 r87  
    3333        : osg::Drawable()
    3434{
     35        #include <leakDetection.h>
    3536    setDataVariance(osg::Object::DYNAMIC);
    3637    setUseVertexBufferObjects(false);
  • osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp

    r55 r87  
    3636                , _skyboxSize(0)
    3737{
     38        #include <leakDetection.h>
     39       
    3840    setDataVariance(osg::Object::DYNAMIC);
    3941    setUseVertexBufferObjects(false);
  • osgVisual/src/sky_Silverlining/visual_skySilverLining.cpp

    r73 r87  
    2121visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_)
    2222{
     23        OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining..." << std::endl;
     24        #include <leakDetection.h>
     25
    2326        atmosphereInitialized = false;
    2427        postInitialized = false;
Note: See TracChangeset for help on using the changeset viewer.