Reputation: 32805
I already know that I can trace memory leaks in my code with mtrace
and valgrind
on Linux, both of which are unavailable for Windows. Which Windows program would you recommend to trace memory leaks?
I'm an Eclipse user and I've been working with C for a month or two now, so I prefer a user-friendly solution over something more advanced.
Upvotes: 3
Views: 6868
Reputation: 74702
Application Verifier will do this quite well, http://msdn.microsoft.com/en-us/library/ms220948.aspx
Upvotes: 2
Reputation: 34592
There is a common sense way of doing this, in the lines of C, for every pair of malloc
there is a free
, if there isn't there's a leak, likewise the same for the GlobalAlloc
, VirtualAlloc
, HeapAlloc
, LocalAlloc
, VirtualAllocEx
...there's an associated ...Free
pair with them, for example running a HeapAlloc
on variable 'foo' for example, and there is no HeapFree
for 'foo', that is a leak...
Hope this helps, Best regards, Tom.
Upvotes: 0
Reputation: 5650
You can hook up e.g. visual leak detector as described here: http://www.codeproject.com/KB/applications/visualleakdetector.aspx
Another way would be to do count the amount of memory used before and after a specific action. Like described here: msdn.microsoft.com/en-us/library/aa293901%28VS.60%29.aspx Something like this can easily added to e.g. automatic unit tests.
Upvotes: 0
Reputation:
You can use _CrtDumpMemoryLeaks. I suppose it is similar to mtrace.
More info: http://www.codeguru.com/forum/showthread.php?t=312742
Upvotes: 2