How you find memory leaks?
Answers were Sorted based on User's Feedback
Answer / jawahar
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
Is This Answer Correct ? | 8 Yes | 0 No |
Answer / umesh pai
There is a pretty easiest way to identify whether ur application is having any memory leak. By using the macro called DEBUG_NEW
define this macro on each of urs cpp file.
like #define DEBUG_NEW
then if u run once ur application in debug mode, it will show each variable which has not been released the memory properly.
Is This Answer Correct ? | 8 Yes | 3 No |
Answer / gopal sodhani
macro should be
#define new DEBUG_NEW, in such case once you insert this
directive, the preprocessor will insert DEBUG_NEW wherever
you use new, and MFC does the rest.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / nibha
there are various tool like UMDH,DevPartner, through which
can get line number and function name where memory is
leaking
Is This Answer Correct ? | 3 Yes | 0 No |
What types of threads are supported by MFC framework?
I want recent paper pattern for HP company?
what is the difference between SDI and MDI
15 Answers CMC, HCL, Siemens,
What is the size of class
How can i change the color of a dropdowncombobox elements
How to access document object from view ?
Q1. A. What is unary operator? List out the different operators involved in the unary operator. B. What is an adjust field format flag? Q2. A. Distinguish between a # include and #define. B. Can a list of string be stored within a two dimensional array? Q3. A. Explain how a pointer to function can be declared in C++? B. List the merits and demerits of declaring a nested class in C++? Q4. A. What are the syntactic rules to be avoid ambiguity in multiple inheritence? B. Explain the operation of overloading of an assignment operator. Q5. A. Explain how the virtual base class is different from the conventional base classes of the opps. B. Explain how an exception handler is defined and invoked in a Program. Q6. A. What is a binary file? List the merits and demerits of the binary file usagein C++. B. Write short notes on Text Manipulation Routines. C. Write bites in Turbo c++ Header ("Include") Files.
Types of DLL's
1)dynamic creation of a Button ?
What MFC base classes provide support for ActiveX controls?
What is the difference between the Encapsulation and Abstraction
25 Answers HCL, Invensys, TCS, Wipro,
I have 2 threads. One thread prints odd numbers and the second thread prints even numbers. Now, I have to execute the threads alternatively so that i can output 1,2,3,4,5,6,..... write code for this?