Re: g_print memory leak according to mtrace v2.3.2

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

 



On Thu, 2004-09-09 at 09:58, Kurt Newman wrote:
> I'm using Glib v2.4.2.  To re-create my suspicion, do the following:
> 
> 1) create a file with the following (simple stuff)
> 
> /* ghelloworld.c */
> #include <glib.h>
> #include <mcheck.h>
> 
> int main(void) {
>    mtrace();
>    g_print("Hello World\n");
>    /* printf("Hello World\n"); */

What about running g_print in a loop?  Note that many g_ functions have
static overhead that often show up as a memory leak but they really
don't have leaks.  IE they may claim some memory, but it is freed when
the program quits and is not allocated every time the function is 
called.

>    muntrace();
>    return(0);
> }
> 
> 2) build it
> 
> > gcc -o ghelloworld ghelloworld.c `pkg-config --cflags glib-2.0`
> `pkg-config --libs glib-2.0`
> > export MALLOC_TRACE='mtrace.log'
> > ./ghelloworld
> 
> (outputs a mtrace.log to the cwd)
> 
> > mtrace ghelloworld mtrace.log
> 
> Memory not freed:
> -----------------
>    Address     Size     Caller
> 0x0804a378     0x20  at 0x4004f0d7
> 0x0804a3a0     0x14  at 0x4004f15f
> 0x0804a3b8     0x1e  at 0x4004f0d7
> 0x0804a3f8     0x34  at 0x4004f0d7
> 0x0804a430    0x400  at 0x4004f0d7
> 0x0804a838      0xc  at 0x4004f15f
> 0x0804a848     0x34  at 0x4004f0d7
> 0x0804a880     0x14  at 0x4004f0d7
> 0x0804a898    0x400  at 0x4004f0d7
> 0x0804aca0     0x34  at 0x4004f0d7
> 0x0804acd8    0x400  at 0x4004f0d7
> 
> 3) Commenting out the g_print() and uncommenting out printf(),
> rebuilding, and then running ghelloworld over again yield no memory
> leaks (according to mtrace).
> 
> Am I using g_print incorrectly?  More specifically, am I misusing or not
> initializing something?
> 
> 
> ______________________________________________________________________
> _______________________________________________
> 
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list
-- 
Michael L Torrie <torriem@xxxxxxxxxxxx>

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux