MFC Question:
Download Job Interview Questions and Answers PDF
How you find memory leaks?
Answer:
There many ways to find memory leaks, One of the ways is by
using MFC class. And another way is using Purify tools...
CMemorState is a MFC class by which we can find the memory
leaks. Below is a sample code to find the same.
#ifdef _DEBUG
CMemoryState oldState, newState, diffState;
oldState.Checkpoint();
#endif
int* a = new int[10];
#ifdef _DEBUG
newState.Checkpoint();
if(diffState.Difference(oldState, newState))
{
TRACE0("Memory Leaked");
}
#endif
using MFC class. And another way is using Purify tools...
CMemorState is a MFC class by which we can find the memory
leaks. Below is a sample code to find the same.
#ifdef _DEBUG
CMemoryState oldState, newState, diffState;
oldState.Checkpoint();
#endif
int* a = new int[10];
#ifdef _DEBUG
newState.Checkpoint();
if(diffState.Difference(oldState, newState))
{
TRACE0("Memory Leaked");
}
#endif
Download MFC Interview Questions And Answers
PDF
Previous Question | Next Question |
What is the base class for MFC? | If application hangs while SendMessage is waiting for the result, how you handle it? |