Re: finding memory leaks



Jim Edwards <jimedwards altavista com> writes:
> 
> I´m trying to chase memory leaks in a farily large program.  I´ve tried
> memprof but for whatever reason it doesn´t work, so I´m using mtrace.
> The output from mtrace gives me a whole list of  memory not freed  but
> it often only gives me an address for the caller.  I assume these are
> malloc calls from glib (Is this a good assumption?)   The question is
> how do I compile and link glib and/or gtk to get the source location of
> the caller rather than
> just the address?
> 
> I see in the configure for glib are some  flags --enable-mem-check,
> --enable-mem-profile  can anyone tell me what these do and wether the
> can help?

They are pretty useless, but --enable-gc-friendly is useful for you
here, it makes leak detectors and memory profilers work much better by
keeping GLib from caching hunks of allocated memory for GSList etc.

mtrace is really useless for most programs, since most programs do not
bother to free all outstanding allocations on exit. Which is fine, the
OS will clean up the memory. To use mtrace you'll have to be very
careful to have _shutdown() routines which clean up everything, and
call them on exit. memprof is much better because it checks whether
you have leaked the memory, not whether you have freed it.

Havoc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]