Re: gtkevent memory leak



On Thu, 2003-12-11 at 17:15, Brandon M. Reynolds wrote:
> It seems that gtkentry has some memory leaks.  Ignore the
> glib_set_memtrace() calls.  I seem to have to call
> g_signal_handlers_destroy() because there are several signal handlers
> assigned to im_context in gtk_entry_init().  I guess these should be dealt
> with in gtk_entry_finalize().

A) glib_set_memtrace() is very much not useful, and may *cause*
   memory leaks, if I remember correctly.

B) Calling gtk_widget_destroy() on a newly created child 
   widget will leak the widget. Understanding why this is 
   so requires understanding the concept of  floating
   reference counts:

   http://developer.gnome.org/doc/GGAD/z57.html

   has an explanation. (it's out of date in other way,s
   but this hasn't changed.)

D) You cannot call g_signal_handlers_destroy() on any 
   GObject

E) You cannot call g_free() on any GObject.

Regards,
					Owen


> #include <gtk/gtk.h>
> int main(int argc, char *argv[])
> {
>   GtkWidget *widget;
>   extern void glib_set_memtrace(int);
> 
>   gtk_init (&argc, &argv);
> 
>   widget = gtk_entry_new();
>   gtk_widget_destroy(widget);
>   g_free(widget);
> 
>   glib_set_memtrace(1);
> 
>   widget = gtk_entry_new();
> 
>   g_signal_handlers_destroy(GTK_ENTRY(widget)->im_context);
>   gtk_widget_destroy(widget);
> 
>   g_free(widget);
> 
>   glib_set_memtrace(0);
> 
>   return 0;
> }





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