2
Vote

Provide a project template to support CRT debugging features

description

There have been suggested to support the Debug CRT for detecting memory leaks. Basically it requires two modifications the the test dll project.

First, add the following lines to the test dll's stdafx.h file:

define _CRTDBG_MAP_ALLOC

include <crtdbg.h>

And second, insert the following as the first line in the test dll's main .cpp dll file:
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);


e.g.,

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
int nRetCode = 0;

.

comments

icnocop wrote Mar 31, 2011 at 4:08 AM

_tmain is an entry point for an application, not a dll.

I followed the steps here:
Finding Memory Leaks Using the CRT Library
http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx

I called "_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );" within BEGIN_TEST(){ ... }END_TEST but could not get the file and the line number where the leaked memory is first allocated.

Any ideas?

Thank you.

wrote Feb 14, 2013 at 7:21 PM