summaryrefslogtreecommitdiffstats
path: root/source/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/main.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/source/main.cpp b/source/main.cpp
index 37b3be5ac..835d7ffc7 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -17,6 +17,22 @@
+/// If defined, a thorough leak finder will be used (debug MSVC only); leaks will be output to the Output window
+#define ENABLE_LEAK_FINDER
+
+
+
+
+
+#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
+ #define XML_LEAK_FINDER
+ #include "LeakFinder.h"
+#endif
+
+
+
+
+
void ShowCrashReport(int)
{
@@ -27,17 +43,31 @@ void ShowCrashReport(int)
exit(-1);
}
+
+
+
+
int main( int argc, char **argv )
{
(void)argc;
(void)argv;
-#ifdef _DEBUG
+
+ #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
+ InitLeakFinder();
+ #endif
+
+ #ifdef _DEBUG
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
-#endif
-
-#ifndef _DEBUG
+
+ // _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output)
+ // Only useful when the leak is in the same sequence all the time
+ // _CrtSetBreakAlloc(85950);
+
+ #endif
+
+ #ifndef _DEBUG
std::signal(SIGSEGV, ShowCrashReport);
-#endif
+ #endif
try
{
@@ -53,12 +83,17 @@ int main( int argc, char **argv )
LOGERROR("Unknown exception!");
}
-#if USE_SQUIRREL
+ #if USE_SQUIRREL
SquirrelVM::Shutdown();
-#endif
+ #endif
-#ifdef _DEBUG
- _CrtDumpMemoryLeaks();
-#endif
+ #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
+ DeinitLeakFinder();
+ #endif
+
return 0;
}
+
+
+
+