Memory Leak detection
-
To start with, I wrote tons of code and still does. However, I am using someone else's application and I need to prove it's causing memory leaks. Since this application runs for days, the leaks are finally halting the system. The problem is we have multiple applications running on the background and we need to find the culprit. Sounds better ?
-
Shay Harel wrote:
Sounds better ?
few... as the program is not running alone on its machine, there could be leaks at several places.
TOXCCT >>> GEII power
[toxcct][VisualCalc]Which was my original question... Is there any application out there that somehow monitors memory usage per application so I can see if any of the applications just consume more and more memory.
-
Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay
Configure the application for 'constant' behavior. That is some well-defined repeatable behavior that should USE memory but not LEAK memory. Set up performance monitor to watch this application's working set size and private bytes. Chart over a day or two, or until application halts. Then see if that application has a constantly growing use of the working set size and private bytes. You can probably assume it has a memory leak.
-
Configure the application for 'constant' behavior. That is some well-defined repeatable behavior that should USE memory but not LEAK memory. Set up performance monitor to watch this application's working set size and private bytes. Chart over a day or two, or until application halts. Then see if that application has a constantly growing use of the working set size and private bytes. You can probably assume it has a memory leak.
I will try that
-
Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay
To find memory leaks using just Visual stidio,- is unappropriate complex task. visual studio does only small chek and nothing more, so slightly complex errors remains hardly found. Best and easy way to use specialized program like BoundsChecker, or something like this.
-
Which was my original question... Is there any application out there that somehow monitors memory usage per application so I can see if any of the applications just consume more and more memory.
-
Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay
I like to drop in MMGR. Add it to your project, then read the comments in mmgr.cpp to use it. It will record every allocation without adding the header file to your project files, but it won't record the file and line number of the allocation unless the mmgr.h is included. It can record every memory allocation or only mem leaks in a text file that's easy to read. It helped me spot places where I allocated an array of characters, eg. I used
delete item;
on an array called item instead of
delete[] item;
and things like that. There are plenty of asserts in there with comments that tell you what you did wrong to cause the assertion.
-
I like to drop in MMGR. Add it to your project, then read the comments in mmgr.cpp to use it. It will record every allocation without adding the header file to your project files, but it won't record the file and line number of the allocation unless the mmgr.h is included. It can record every memory allocation or only mem leaks in a text file that's easy to read. It helped me spot places where I allocated an array of characters, eg. I used
delete item;
on an array called item instead of
delete[] item;
and things like that. There are plenty of asserts in there with comments that tell you what you did wrong to cause the assertion.
FWIW, I do not think that kind of error causes a memory leak directly (only indirectly). Missing the
[]
operator causes only the first object in the array to have its destructor called, but the memory block itself is still freed. For example, if you missed the brackets on an array of simple types, there should be no memory leaks. However, if the array was an array of complex objects that themselves allocate memory, then that might indirectly cause leaks because the destructors will not be called on objects 2-n in the array. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay
This may be a dumb question, but why can you not just use Task Manager, and look at the memory consumption of the process in question? Over time, if leaks do exist, you should be able to see an increase in total memory usage over time. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
This may be a dumb question, but why can you not just use Task Manager, and look at the memory consumption of the process in question? Over time, if leaks do exist, you should be able to see an increase in total memory usage over time. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)yes, this is a "memory leak" 101 thing. I was looking for something that will do that for me and have some reporting instead of me having to look at it all the time.