i saw this page and found that we can check memory leaks of a program using dbx.
i never practically did it but it seems a good toll for checking the memory leaks.
i used to work on HPUX and IBM AIX UNIX OS's,where there is no GUI and always used to work on command line.
the library rtcaudit.so(for runtime checking) is provided by Sun.
does it mean that this library is only available on sun solaris?
you may tell me why cant i try myself.but the problem here is i am not presently working on unix but on windows.I am just eager to know whether we can use the same thing either in HPUX or IBM AIX.
does anybody know about this?Please share it in case you know it
An open source alternative is Valgrind. This not only detects memory leaks, but also other kinds of memory errors and a bunch of other stuff I've never used. It currently only runs on Linux, MacOS, FreeBSD, and NetBSD, but if your program is not platform dependent then you could develop and debug on one platform before running it on your target platform.
rtcaudit.so is part of Oracle Solaris Studio (formerly known as Sun Studio). Despite the name it also runs on Linux x86. So if you have a Linux box and some time you may want to try it there. (In that case you may want to try Valgrind first, see Scotts answer.)
For HP there is Wildebeest Debugger (WDB) (a modified gdb). WDB has its own extensions to find memory leaks. While these are different from Suns dbx, you still might want to give it a try.
If you are using Visual Studio, it does offer some support to find memory leaks. See
Memory Leak Detection and Isolation on MSDN.
There are some free Libraries to catch this type of errors. For Windows there are e.g.:
Electric Fence and
Visual Leak Detector. (Can't post the links because I don't have enough reputation points.)
PS: If I run into problems like this, the first thing I try is Valgrind (see Scotts answer). It doesn't require any interaction but simply spits out lots of useful information. While it is not a full debugger, many times it gives enough hints to fix an error. Highly recommended! Does not run on Windows though.
You may want to have a look at this question, this question and this question here at stackoverflow.com.