Re: gtk2-perl / a script to help converting basic functions



Guillaume Cottenceau <gc mandrakesoft com> writes:

Do we have an helpful tool to efficiently/easily check for memory
leaks?

Ok, I've:

- added a misc-examples/test-memoryleak.pl to ease up tests for
  memory leaks (calls 5000 times a closure and print the size of
  the process before and after);

- written newSVgchar in _Helpers that does what you suggested
  (converts to an SV* then g_free the gchar*), to be used with
  allocated gchar* returned back by gtk; fixed TextBuffer and
  genscripts/convert_funcs.pl accordingly


It seems that doing what you suggested fixed the memory leak of
the gchar*; but it seems that there is another big leak we didn't
know about, it's destructors; here's the output of
test-memoryleak.pl:

---- mem:   8516 kB -- TextView get_text
---- mem:  12032 kB 

---- mem:  12032 kB -- TextView get_text with static bounds
---- mem:  12032 kB 

---- mem:  12144 kB -- Button get_label
---- mem:  12148 kB 

---- mem:  12148 kB -- Button new
---- mem:  14012 kB 


The first test leaks memory probably because it calls
TextBuffer::get_bounds which create each time two Gtk2::TextIter
objects, and the last test leaks memory just by creating a new
button with no label...

Goran, have you looked at the problem of object destruction?

It seems that in gtk-perl there is pretty much code for that (in
Gtk/GtkTypes.c)... including a garbage collector handled by hand!


-- 
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/



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