]> git.saurik.com Git - wxWidgets.git/commitdiff
added call to _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF) for
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 7 Aug 1998 22:07:03 +0000 (22:07 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 7 Aug 1998 22:07:03 +0000 (22:07 +0000)
VC++: it gives at the end of the program report about memory leaks if any
similar to the one produced by the wxwin memory diagnostic classes (but it
works without problems with VC++ and costs nothing to add)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@457 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/app.cpp

index af539d7bf018ce226cafa0e11e6f1cd12e33e002..f2364971079f3e9993e8da8074f8758c8395bdf3 100644 (file)
 #include <commctrl.h>
 #endif
 
+// use debug CRT functions for memory leak detections in VC++
+#if defined(__WXDEBUG__) && defined(_MSC_VER)
+  #include <crtdbg.h>
+#endif
+
 extern char *wxBuffer;
 extern char *wxOsVersion;
 extern wxList *wxWinHandleList;
@@ -332,6 +337,7 @@ void wxApp::CleanUp()
     delete wxWinHandleList ;
 
   // do it as the very last thing because everything else can log messages
+  wxLog::DontCreateOnDemand();
   delete wxLog::SetActiveTarget(NULL);
 }
 
@@ -424,6 +430,13 @@ int wxEntry(WXHINSTANCE hInstance, WXHINSTANCE WXUNUSED(hPrevInstance), char *m_
 {
   wxhInstance = (HINSTANCE) hInstance;
 
+  #if defined(__WXDEBUG__) && defined(_MSC_VER)
+    // do check for memory leaks on program exit
+    // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
+    //  deallocated memory which may be used to simulate low-memory condition)
+    _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
+  #endif // debug build under MS VC++
+
 #if (WXDEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT
 
 #if !defined(_WINDLL)
@@ -434,7 +447,7 @@ int wxEntry(WXHINSTANCE hInstance, WXHINSTANCE WXUNUSED(hPrevInstance), char *m_
   ostream* oStr = new ostream(sBuf) ;
   wxDebugContext::SetStream(oStr, sBuf);
 
-#endif
+#endif  // USE_MEMORY_TRACING
 
   if (!wxApp::Initialize((WXHINSTANCE) wxhInstance))
     return 0;