Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Free Application to check Memory Leaks in Windows x64?

I have been assigned to check memory leak for an API by my boss. The Application is created in C & C++. So there is a possibility that memory is allocated using malloc & new. I want to check the memory leak in Visual Studio 2010 in debugger mode in 64 bit Windows 7. The problem with task manager is that it is not showing stable readings (memory increasing & decreasing by small amounts). Also the difference is small before & after the API is run. So i cannot defitely say that x amount of memory is leaking per cycle.

I have searched on the internet & found that linux has a great tool for this. However I want a reliable tool for my requirements (Windows 7). I have come across these:

http://winleak.sourceforge.net/

http://sourceforge.net/projects/duma/?source=recommended

As mentioned over here:

check Memory leaks in windows

the tool

http://technet.microsoft.com/en-us/library/bb457063.aspx

is not useful for my requirements. It would be very helpful of you guys if you could please suggest a good tool, as the customer who is requesting this is very important for our company. Thank You!

like image 217
Cool_Coder Avatar asked Jan 09 '13 13:01

Cool_Coder


People also ask

How do I find a memory leak in Windows?

Press Windows+R to open the Run dialog; enter "resmon" and click OK. With Resource Monitor open, select the Memory tab. Looking at Physical Memory, start by confirming the correct amount is displayed as installed, to ensure that there isn't a hardware issue.

What is the best tool to detect memory leaks?

Using Memory Profilers Memory profilers are tools that can monitor memory usage and help detect memory leaks in an application. Profilers can also help with analyzing how resources are allocated within an application, for example how much memory and CPU time is being used by each method.

How do I check for memory leaks in a program?

The best approach to checking for the existence of a memory leak in your application is by looking at your RAM usage and investigating the total amount of memory been used versus the total amount available. Evidently, it is advisable to obtain snapshots of your memory's heap dump while in a production environment.

Does Visual Studio detect memory leaks?

The Visual Studio debugger and C Run-time Library (CRT) can help you detect and identify memory leaks.


2 Answers

I suggest using visual leak detector as it have served me well several times. You may also try to use valgrind for windows (although I had little success on doing that).Dr. Memory also helped me a few times.

EDIT: also have a look here.

like image 191
Ivaylo Strandjev Avatar answered Sep 25 '22 08:09

Ivaylo Strandjev


The CRT library has its own memory leak detection mechanism. The output is not as detailed as what Visual Leak Detector gives you, but it is a lot faster than VLD (which easily runs for dozens of minutes after the program exits).

To enable CRT memory leak detection place the following at the beginning of stdafx.h (or somewhere else suitable):

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

Add the following right before the program's exit point(s):

_CrtDumpMemoryLeaks();

When _CrtDumpMemoryLeaks() is called it prints all leaked memory it can find to the output window.

More information on MSDN.

Note: When I used this I only got the less detailed output without line numbers although I had defined _CRTDBG_MAP_ALLOC right at the beginning of stdafx.h.

like image 38
Helge Klein Avatar answered Sep 26 '22 08:09

Helge Klein