For debugging purposes, when I write the application, the first thing I do is put in stdafx.h:
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
Then I will add the following to the beginning of the main () function of the program:
#ifdef _DEBUG
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
Revising a new operator to provide leak information is a useful tool. But what about CoTaskMemAlloc and CoTaskMemFree? How can I detect leaks using these?
I am writing software using COM and DirectShow, and you need to know how to track leaks caused by using CoTask distributions.
thank!
user206705
source
share