Re: memory leaks destroying widgets




judd montgomery <judd@engineer.com> writes:

> I have an application in which I create lots of widgets.  clists, text
> boxes, entries, etc.  Then I destroy the box that they are all packed
> into using gtk_widget_destroy() and then I redraw more widgets, and then
> I repeat this process.  Why do I have memory leaks?  Should I be doing
> something more?

That should work. Without more information it is hard
to say why you are leaking memory.

(When I say that it works, it works assuming that box
 is packed into a toplevel.

  box = gtk_hbox_new (FALSE, 0);
  label = gtk_label_new ("Hi");
  gtk_container_add (GTK_CONTAINER (box), label);
  gtk_widget_destroy (box);

 Leaks both the box and the label. 

 A widget is created with a reference count of 1; this
 reference count is taken over by a parent when you add
 it to a parent.)

Regards,
                                        Owen



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