Re: GtkPerl-based programs leak memory like crazy



disclaimer:  i am not a Gtk-Perl developer, just a Gtk-Perl user.

Vlad Harchev wrote:

while (1) { iter(); } ---------------
leaks about 100kb of memory per second.

most obviously, this one never gives the idle-time garbage collector a 
chance to run.

Gtk->idle_add(sub { iter(); 1; });
main Gtk;
----------------

leaks about 40 kb/second.

here, i don't know. again, since this is running on idle and not on a timeout, this might not be giving gc a chance.


from what i can tell from the source (not a comprehensive search, just things i've noticed over a few months), GtkPerl likes to cache things in the interest of speed, and uses a garbage collector that runs on idle. you can, indeed, trigger the garbage collection by hand (Gtk->gc according to man Gtk::reference).
there are indeed known leaks in a few places, such as passing a list of 
args to a callback (leaks because there is no API-defined way to hook to 
the destruction of the callback data); in general, these tend to be 
things that you'll do once in a program, but that is not always true of 
course.
have a look at Gtk-Perl-0.7008/Gtk/xs/GtkItemFactory.xs and 
Gtk-Perl-0.7008/Gtk/xs/GtkObject.xs for examples of the known leaks and 
see if you can figure out how to plug them.





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