Home > Software engineering >  MFC check memory leaks
MFC check memory leaks

Time:10-31

Checked online, use CRT debug heap functions, in StdAfx. H file add
# define _CRTDBG_MAP_ALLO
#include
At the end of the each function add _CrtDumpMemoryLeaks ();

When to generate pop-up window will display memory leaks, minimize afresh again open also can prompt disclosure
C: \ documents and Settings \ administrator \ \ distanceview desktop CPP (32) : {727} client block at 0 x01549df8, subtype c0, 928 bytes long.
A CDistanceView object df8 at $01549, 928 bytes long
F: \ dd \ vctools \ vc7libs \ ship \ atlmfc \ SRC \ MFC \ strcore CPP (156) : {723} normal block x01549bd0 at 0, 25 bytes long.
Data: & lt; T y & gt; 54 CD 07 79 08 00 00 00 00 00 00 08 01 00 00 00
F: \ dd \ vctools \ vc7libs \ ship \ atlmfc \ SRC \ MFC \ strcore CPP (156) : {722} normal block x01549b78 at 0, 25 bytes long.
Data: & lt; T y & gt; 54 CD 07 79 08 00 00 00 00 00 00 08 01 00 00 00
F: \ dd \ vctools \ vc7libs \ ship \ atlmfc \ SRC \ MFC \ strcore CPP (156) : {721} normal block at 0 x01549af0, 69 bytes long.
Data: & lt; T y4 4 & gt; 54 CD 07 79 34 00 00 00 00 00 00 01 00 00 00
Pointers to the IMPLEMENT_DYNCREATE CDistanceView, CFormView,

C: \ documents and Settings \ administrator \ \ mainfrm desktop CPP (18) : {720} client block at 0 x01549808, subtype c0, 680 bytes long.
A CMainFrame object at $01549808, 680 bytes long
Pointing to the IMPLEMENT_DYNCREATE (CMainFrame CFrameWnd)

C: \ documents and Settings \ administrator \ \ desktop qualitative 4.7 continuous \ distancedoc CPP (18) : {719} client block at 0 x015496e0, subtype c0, 236 bytes long.
A CDistanceDoc object e0 at $015496, 236 bytes long
Pointing to the IMPLEMENT_DYNCREATE (CDistanceDoc CDocument)

C: \ documents and Settings \ administrator \ \ desktop qualitative 4.7 continuous \ short CPP (76) : {715} client block at 0 x01549478, subtype c0, 140 bytes long.
A CSingleDocTemplate object at $01549478, 140 bytes long
Point to pDocTemplate=new CSingleDocTemplate (

There are many is f: \ dd \ vctools \ vc7libs \ ship \ atlmfc \ SRC \ MFC \ * * * * * * * * * * * at the beginning of

Check the memory leak for the first time, there are a lot of things are not clear, after should reveal how to judge?

CodePudding user response:

In each function is added _CrtDumpMemoryLeaks not fault, at the end of the program to add ah,
_CrtDumpMemoryLeaks snapshot is contrast examination within what memory did not release, we generally say the memory leak is not released no longer use memory,
There must be some in the operation of the no release, but still in use

CodePudding user response:

MFC already bring the function of memory leak detection, can try

CodePudding user response:

reference 1st floor dustpg response:
in each function is added _CrtDumpMemoryLeaks not fault, at the end of the program to add ah,
_CrtDumpMemoryLeaks snapshot is contrast examination within what memory did not release, we generally say the memory leak is not released no longer use memory,
There must be some in the operation of the no release, but still in use.


It calls on MFC? Search:
Commonly used in the MFC is accurate, in InitInstance call _CrtDumpMemoryLeaks
Is this for?

CodePudding user response:

In ExitInstance () with the _CrtDumpMemoryLeaks (),
Use _CrtSetBreakAlloc () to make program interrupt,
View the call stack, see:

How to see it?
However, there are part of the is not interrupted, 58, for example, it may be the reason why?

CodePudding user response:

You first find hints of lines of code, layers to your code, and then see if the corresponding code in suspicious

CodePudding user response:

I used to use is VLD tool to check memory leaks, there are many tools
With the benefits of the tool tip is to double-click the memory leak positioning to line ~ ~ ~ ~

CodePudding user response:

The
reference 5 floor oyljerry reply:
you find tips on the number of lines of code, first layers to your code, and then see if the corresponding code in suspicious


Shift + F11?
  • Related