hi pals,
i would like to know whether my application has got memory leaks or not?is there any way that i can find?do help me.Thanks in advance.
VCVCVC
Printable View
hi pals,
i would like to know whether my application has got memory leaks or not?is there any way that i can find?do help me.Thanks in advance.
VCVCVC
Problems with new / delete allocations on the heap can be discovered using this code :
/////////////////////////////////////////////////////////////////////////////
// FindMemoryLeaks
#ifdef _DEBUG
#include "crtdbg.h"
class FindMemoryLeaks
{
_CrtMemState m_checkpoint;
public:
FindMemoryLeaks()
{
_CrtMemCheckpoint(&m_checkpoint);
};
~FindMemoryLeaks()
{
_CrtMemState checkpoint;
_CrtMemCheckpoint(&checkpoint);
_CrtMemState diff;
_CrtMemDifference(&diff, &m_checkpoint, &checkpoint);
_CrtMemDumpStatistics(&diff);
_CrtMemDumpAllObjectsSince(&diff);
};
};
#endif
Add this code to your applications main cpp file, before your CWinApp based class. Within your apps InitInstance(), add the following code right at the top of that function :
#ifdef _DEBUG
FindMemoryLeaks fmt;
#endif
When you stop your program on a debug run, the debug output window will detail all allocations with new / malloc, and also report where they haven't been deleted. You can double click on the line in the debug window to take you to the source with the problem (usually a 'new()' statement).
For other problems such as gdi or windows resource leaks, there are a number of tools and articles on the MSDn site you can find here : http://msdn.microsoft.com/library/de...html/leaks.asp . The gdileak.exe is excellent.
For all others leak types, take a look at Numega Bounds Checker (visit www.compuware.com and follow the evaluation links. You cannot download an eval version directly, you have to phone the company to request an eval version. They will give you one though. Another good product you can evaluate is Rational Rose Purify.
Jase
http://www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
1 point for my life story ? There's no pleasing some people :)
Jase
http://www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
Do you have a link for this application? It does not turn up in a search on the internet or on Microsoft. Also, the Microsoft link is no longer valid.
Hi Bob
I'm sorry if Microsoft have broken their links since I made this post, searching for appropriate terms in the knowledge base and technical articles should find similar content.
I will attach gditest.exe to this thread when i get home later tonight, it's a very small exe. It's a useful tool, it shows you all the gdi handles in use by the system in realtime, so you can see when testing your application if they are growing out of hand due to leaks etc ...
Jase
Here it is ..
a very good debugger to find memory leaks is BoundsChecker (now distributed by Compuware).
You can download a trial version.
After several days searching for a weird problem, I installed BC, and very soon I could locate the problem.
So, my boss was easily convinced to spend the money ;-)