How can I detect memory leaks in QtCreator on Windows? On the doc, they recommend Memcheck but it only works on Mac and Linux. Any suggestion for Windows?
解决方案
So after many tries I finally found a method to detect the memory leaks of a Qt project on Windows:
1) First, it cannot be done directly in Qt Creator so you need to create a Visual C++ project to do the memory leak detection. Thankfully, qmake makes this easy. Open the Qt SDK command line tool and run:
qmake -spec win32-msvc2008 -tp vc
This will convert your project to a .vcproj.
2) Open this project and add the necessary code for memory leak detection:
To your main.cpp file:
// Necessary includes and defines for memory leak detection:
#ifdef _MSC_VER
#define _CRTDBG_MAP_ALLOC
#include
#endif // _MSC_VER
#if defined(_MSC_VER