Re: [gtk-list] Memory debugging with GTK+ and glib




On Sun, 25 Jul 1999, David Allen wrote:
> 
> I've come across a resource for checking up on the memory usage of
> different programs, but it seems that there are only programs that
> help out with problems relating to malloc() calloc() and free() but
> not to things like g_new() g_new0() and g_free() - the usual
> information that applications would print out when linked in with your
> application in GTK+ don't show up, ostensibly because I'm not using
> malloc() calloc() and free();
> 

The g_ functions are just wrappers around malloc() and free(). They also
have some memory debugging built-in. (Build your glib with some special
define - I forget, but a quick look at gmem.c will tell you - then call
g_mem_profile() or something like that.) But Purify, Insure++, ccmalloc,
etc. should all work. The only catch is that glib caches allocated memory
in some cases, I think the latest FAQ has some stuff about that.

On glibc systems (i.e. newer Linux distributions, primarily) it's also
useful to use the MALLOC_CHECK_ environment variable - it may be
documented in the glibc reference manual. Anyway if you set it to "2"
freeing bad pointers will immediately cause an abort(), and setting it to
1 has some other effect (maybe prints a message or something, I don't
remember).

Havoc




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