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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.