win32: rework CHECK_MEMORY_LEAKS to dump after static object deinit

This commit is contained in:
OV2 2017-10-13 22:37:39 +02:00
parent 17b3a81419
commit e014129b12
4 changed files with 21 additions and 7 deletions

17
win32/DumpAtEnd.cpp Normal file
View File

@ -0,0 +1,17 @@
// uncomment to find memory leaks at end
// #define CHECK_MEMORY_LEAKS
// to also display file locations in some cases define _CRTDBG_MAP_ALLOC in the project properties
#ifdef CHECK_MEMORY_LEAKS
// hack to make sure this object is destructed last
// msvc merges .CRT$XC in alphabetic order
// might not work in other versions of MSVC
#pragma init_seg(".CRT$XCB")
struct CallDumpMemLeaksLast {
~CallDumpMemLeaksLast() {
_CrtDumpMemoryLeaks();
}
};
static CallDumpMemLeaksLast dump_last;
#endif

View File

@ -534,6 +534,7 @@
<ClCompile Include="COpenGL.cpp" />
<ClCompile Include="CXAudio2.cpp" />
<ClCompile Include="CXML.cpp" />
<ClCompile Include="DumpAtEnd.cpp" />
<ClCompile Include="dxerr.cpp" />
<ClCompile Include="InputCustom.cpp" />
<ClCompile Include="render.cpp" />

View File

@ -539,6 +539,9 @@
<ClCompile Include="..\msu1.cpp">
<Filter>APU</Filter>
</ClCompile>
<ClCompile Include="DumpAtEnd.cpp">
<Filter>GUI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="rsrc\nodrop.cur">

View File

@ -244,13 +244,6 @@
#include "wlanguage.h"
#include "../language.h"
//uncomment to find memory leaks, with a line in WinMain
//#define CHECK_MEMORY_LEAKS
#ifdef CHECK_MEMORY_LEAKS
#include <crtdbg.h>
#endif
#include <commctrl.h>
#include <io.h>
#include <time.h>