LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] memory leaks...

[ILUG] memory leaks...

kevin lyda kevin at suberic.net
Tue Feb 29 22:29:33 GMT 2000


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"




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell