I am sure there are other tools, but I favor valgrind for finding memory
leaks. It can be installed through the package manager.
Run your program with 'valgrind --leak-check=full programname args...'
anmd when it exits (you can ctrl-c it if you need to) you get a report
that will show the exact location (with line number information if
available) where memory was allocated that was not freed. Here's a
sample session using a very foolish program as an example:
$ cat -n leaky.c; gcc -g leaky.c
1 #include <stdlib.h>
2 int main(void) {
3 char *s = 0;
4 int i;
5
6 for(i=0; i<100; i++) {
7 s = malloc(32); // oops!
8 s = malloc(32);
9 free(s);
10 }
11 }
$ valgrind --quiet --leak-check=full ./a.out
==27392==
==27392== 3,200 bytes in 100 blocks are definitely lost in loss record 1 of 1
==27392== at 0x401C422: malloc (vg_replace_malloc.c:149)
==27392== by 0x80483CB: main (leaky.c:7)
(valgrind will report lots of other kinds of errors, too; unfortunately, it
slows down program execution by about a factor of 10)
Jeff
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers