Hi, My Workaround bases also on MFC, but seems to smaller:
My standart project started as an empty console application without MFC. If I enabled only the memory leak detection, i get lots of memory leak notification because OSGS static objects are not clean until the end of the applications leak detection. My solution is: 1. enable the memory leak detection in the main function: Code: int main(int argc, char** argv) { /*// Redirect memory debugging output to console _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); */ //start memory observation _CrtMemState s1; _CrtMemCheckpoint( &s1 ); { // this scope is important!! It'ns nessecary to use OSG in a subscope of the mainfunction to get no false memory leak indications, // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); // instantiate the applications main class osg::ref_ptr<app_core> core = new app_core(arguments); // init app core->initialize(); } // check for leaks _CrtMemDumpAllObjectsSince( &s1 ); return 0; } 2. To disable all false notification based on the static variable problem (e.g. singletons): Edit the MSVC Project: ->project settings: Use of the MFC library: change from "USE WINDOWS STANDARD LIBRARY" to "USE STATIC MFC LIBRARY" (The use of the dynamic MFC dll doesn't work.) In my project, now all false positives disapper and only the (test) memory leak remains. Unfortunately memory leaks are not related to codefiles and codefiles, so fixing is quite problematic. To solve this issue: 3. Enable Codefile and Codeline identification Add a file "memoryLeakDetection.h" or something like this to your project. this File contains: Code: #pragma once #ifdef _DEBUG #include <crtdbg.h> #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__) #define new DEBUG_NEW #else #define DEBUG_NEW new #endif Incude this file in every .cpp file after your corresponding header File. I included the file in the .cpp file to get rid of problems resulting from multiple direct and indirect inclusion in the header file (pragma once doesn't seem to work well in all situations.). Now you should have only named, numbered and true memory leaks in your application :) I hope this spares someone for searchong severals hours for a solution as i did. Cheers, Torben ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15666#15666 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org