Valgrind and GTK



Hi all,

I'm having trouble differentiating between memory leaks in my code and
apparent leaks in GTK when using valgrind.

Even the minimal hello world program from the GTK tutorial:

   http://library.gnome.org/devel/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD

when run as follows (suppression file from http://live.gnome.org/Valgrind):

  export G_SLICE=always-malloc
  export G_DEBUG=gc-friendly
  valgrind --tool=memcheck --leak-check=full --leak-resolution=high \
    --num-callers=50 --show-reachable=yes --suppressions=gtk.suppression \
    helloworld > helloworld-vg.txt 2>&1

on Ubuntu 9.10 reports this:

  ==22566== LEAK SUMMARY:
  ==22566==    definitely lost: 1,449 bytes in 8 blocks
  ==22566==    indirectly lost: 3,716 bytes in 189 blocks
  ==22566==      possibly lost: 4,428 bytes in 107 blocks
  ==22566==    still reachable: 380,505 bytes in 7,898 blocks
  ==22566==         suppressed: 35,873 bytes in 182 blocks

If the leak summary of a 100 line demo program shows over 8000 definitely
lost, indirectly lost, possibly lost and and still reachable blocks, how
am I supposed to find the blocks of memory leaking from my code which is
30000 lines?

I would also like to note that this is a problem faced by other libraries
like GNU libc which solved the problem by adding a function __libc_freeres
to free all its program lifetime allocated memory.

I am aware of this bug:

    https://bugzilla.gnome.org/show_bug.cgi?id=64096

and some of the discussion around it:

    http://mail.gnome.org/archives/gtk-devel-list/2001-November/msg00279.html
    http://mail.gnome.org/archives/gtk-devel-list/2001-November/msg00541.html

but I'm wondering if attitudes might have changed in the almost 10 years
since that bug and thread.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


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