I have done a little research on debugging programs and what I have come to find is memory leaks is a huge problem to a LOT of programmers and that it is hard to debug large programs. I am asking because I think I have a memory leak in my program [says a few articles on google].
My memory in the windows task manager hovers around 915 to 930 MB. After 1 minute
[give or take] of running my pong program, the memory tops out around 1.9 GB and crashes every time.
My book "C++ Programming From Problem Analysis to Program Design" does not cover debugging in detail. Does anyone know of a site that delves into debugging in detail? The thought of not being able to complete a nearly completed project because of some leak is infuriating. Thanks.
Are you talking about a Windows program? Or Linux? Or?? Edit - just noticed you mentioned "Windows Task manager"
And which IDE do you use?
If your talking about Windows + Visual Studio/etc
The debug version of the VC++ CRT has built in diagnostics which can provide list of leaked blocks, including the file/line num, when correctly configured. (VLD builds on this base functionality, e.g. it captures the call stack which ended up allocating the memory)
Among other things, you can tag the memory you allocated so you can tell it apart from that allocated by libraries and the system.
Note that this mechanism will not track memory allocated by mechanism other then new and delete. And it can get a bit confused if you mix STL and the DLL version of the CRT, due to the way STL manages memory.
Thanks but unfortunately I use CodeBlocks. If I cannot find a solution to CodeBlocks, I will probably just have to code w/VS. I don't know if I can find leaks w/CodeBlocks but I am on the look now.
I use CodeBlocks. I ran CodeBlocks debugger and the debugger does not catch anything.
@ Gulshan Singh
I looked to the cygwin site and I think what they say is to use Valgrind on Windows through cygwin I have to rebuild my application "from source". It seems like a lot of work to setup a "unix-like" environment. If you have done so, please tell me if it is feasible to use cygwin.
I have one more question though. I have read that I can use Win 32 API calls to find leakage problems. As a future programmer, would it be a good idea to learn your OS's API?
Well thanks but I solved the problem. I had a load function that was in a loop and it kept loading new pictures and sounds over and over again. Once I put the loading function outside the loop, memory stayed at a constant level. Thanks again. Appreciate the help so much.