i had a question here but i seem to have answered it, so i thought i'd
share...
memory leaks are really annoying. and they're also tough to spot.
glibc provides a method to spot them:
#include <mcheck.h>
and then call mtrace() at the start of main(). compile the program with
-g for debugging, and set the environment variable MALLOC_TRACE to a
file to log memory allocation and freeing. once you've run the program
run this:
mtrace <program> $MALLOC_TRACE
voila, it lists all the memory leaks and the lines where the memory was
allocated.
dunno if this works from c++, but then c++ programs are supposed to leak
like a sieve anyway so does it really matter?
kevin
--
kevin at suberic.net "we were goin' for breakfast. in canada. we
fork()'ed on 37058400 made a deal: if she'd stop hookin', i'd stop
meatspace place: home shootin' people. maybe we were aiming high."
--porter, "payback"
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!