Re: [gtk-list] Memory leak in Glade output?



Anders Melchiorsen wrote:
> 
> Hi there,
> 
> I am happily using the latest Glade for a Gtk+ project of
> mine. However, I run into a rather severe memory leak in the project,
> and I think I have finally traced it to the source output by Glade.
> 
> To end a window created by a Glade function, I simply call
> 
>         gtk_widget_destroy(GTK_WIDGET(window));
> 
> and this worked flawlessly with previous versions of Glade. Is this no
> longer the correct way to close/free the window?

That is the correct way to destroy a window.


> I was rather confused to find that if I opened and closed the window a
> few times right after each other, I would lose memory for each opening
> when it should just be reusing the memory freed from the previous
> incarnation. I have tried adding
> 
>         gtk_widget_unref(GTK_WIDGET(window));
> 
> before the destroying, and it seems to cure the memory
> loss. Unfortunately, it outputs a warning "assertion
> `object->ref_count > 0' failed" which makes me think that this is not
> the correct cure. I do not really understand the source output by
> Glade, so I have a hard time telling what the problem is.
> 
> Am I doing something wrong, or is this in fact a fault in the Glade
> generated source?

It may be a bug in Glade. I did recently change some code regarding
refcounting so that may have caused it.
If you can send me the code which has the problem I'll look into it.

Thanks,

Damon



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