Click here to Skip to main content
15,914,943 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Some doubt on WM_PAINT and MemoryDC Pin
TheGreatAndPowerfulOz13-Dec-05 12:01
TheGreatAndPowerfulOz13-Dec-05 12:01 
QuestionRe: Some doubt on WM_PAINT and MemoryDC Pin
Sanjoy Sinharoy15-Dec-05 5:35
Sanjoy Sinharoy15-Dec-05 5:35 
QuestionHow can I create a PDF using Visual C++? Pin
DanYELL13-Dec-05 4:39
DanYELL13-Dec-05 4:39 
AnswerRe: How can I create a PDF using Visual C++? Pin
TheGreatAndPowerfulOz13-Dec-05 9:29
TheGreatAndPowerfulOz13-Dec-05 9:29 
AnswerRe: How can I create a PDF using Visual C++? Pin
ThatsAlok13-Dec-05 22:08
ThatsAlok13-Dec-05 22:08 
QuestionMemory leak detection Pin
the pink jedi13-Dec-05 4:26
the pink jedi13-Dec-05 4:26 
AnswerRe: Memory leak detection Pin
kdehairy13-Dec-05 6:35
kdehairy13-Dec-05 6:35 
AnswerRe: Memory leak detection Pin
ThatsAlok13-Dec-05 22:11
ThatsAlok13-Dec-05 22:11 
the pink jedi wrote:
Memory leak detection


Here what MSDN say about this :-
To detect a memory leak

Create a CMemoryState object and call the Checkpoint member function. This creates the first memory snapshot.
After your program performs its memory allocation and deallocation operations, create another CMemoryState object and call Checkpoint for that object. This gets a second snapshot of memory usage.
Create a third CMemoryState object and call its Difference member function, supplying as arguments the two previous CMemoryState objects. If there is a difference between the two memory states, the Difference function returns a nonzero value. This indicates that some memory blocks have not been deallocated.
This example shows what the code looks like:

// Declare the variables needed
#ifdef _DEBUG
CMemoryState oldMemState, newMemState, diffMemState;
oldMemState.Checkpoint();
#endif

// Do your memory allocations and deallocations.
CString s = "This is a frame variable";
// The next object is a heap object.
CPerson* p = new CPerson( "Smith", "Alan", "581-0215" );

#ifdef _DEBUG
newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{
TRACE( "Memory leaked!\n" );
}
#endif
Notice that the memory-checking statements are bracketed by #ifdef _DEBUG / #endif blocks so that they are compiled only in Win32 Debug versions of your program.



"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow


cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
QuestionHow to get size of file ??????? Pin
VikramDelhi13-Dec-05 4:01
VikramDelhi13-Dec-05 4:01 
AnswerRe: How to get size of file ??????? Pin
Graham Bradshaw13-Dec-05 4:15
Graham Bradshaw13-Dec-05 4:15 
AnswerRe: How to get size of file ??????? Pin
Tim Smith13-Dec-05 4:26
Tim Smith13-Dec-05 4:26 
AnswerRe: How to get size of file ??????? Pin
ThatsAlok13-Dec-05 19:39
ThatsAlok13-Dec-05 19:39 
GeneralThanks a lot guys Pin
VikramDelhi14-Dec-05 3:39
VikramDelhi14-Dec-05 3:39 
QuestionReplacing open/save dialogs Pin
Krishnan V13-Dec-05 3:42
Krishnan V13-Dec-05 3:42 
QuestionRe: Replacing open/save dialogs Pin
David Crow13-Dec-05 3:57
David Crow13-Dec-05 3:57 
AnswerRe: Replacing open/save dialogs Pin
Krishnan V13-Dec-05 18:26
Krishnan V13-Dec-05 18:26 
QuestionAccess Synchronization in VC++ Pin
zinc_z13-Dec-05 2:35
zinc_z13-Dec-05 2:35 
AnswerRe: Access Synchronization in VC++ Pin
kakan13-Dec-05 3:30
professionalkakan13-Dec-05 3:30 
AnswerRe: Access Synchronization in VC++ Pin
Sheng Jiang 蒋晟13-Dec-05 9:57
Sheng Jiang 蒋晟13-Dec-05 9:57 
QuestionExporting a function from an .exe?? Pin
Gunn31713-Dec-05 2:34
Gunn31713-Dec-05 2:34 
AnswerRe: Exporting a function from an .exe?? Pin
David Crow13-Dec-05 3:58
David Crow13-Dec-05 3:58 
GeneralRe: Exporting a function from an .exe?? Pin
Gunn31713-Dec-05 4:35
Gunn31713-Dec-05 4:35 
GeneralRe: Exporting a function from an .exe?? Pin
toxcct13-Dec-05 5:22
toxcct13-Dec-05 5:22 
GeneralRe: Exporting a function from an .exe?? Pin
Gunn31713-Dec-05 5:36
Gunn31713-Dec-05 5:36 
QuestionProblem with regions Pin
emadns13-Dec-05 2:03
emadns13-Dec-05 2:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.