Bug#291130: libgtk2.0-0: libgtk2 doesn't free memory from destroyed widgets

Sjoerd Simons sjoerd@spring.luon.net (Sjoerd Simons), 291130@bugs.debian.org
Wed, 19 Jan 2005 00:27:42 +0100


On Tue, Jan 18, 2005 at 11:43:02PM +0100, DaVinci wrote:
> Package: libgtk2.0-0
> Version: 2.4.14-2
> Severity: important
> 
>  Hi.
> 
>  Look at this code:
>  
> -------
> #include <gtk/gtk.h>
> 
> int main(int argc, char** argv){
> 	GtkWidget* window;
> 	gtk_init(&argc, &argv);
> 
> 	while(TRUE){
> 		window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> 		gtk_widget_show_all(window);
> 		gtk_object_destroy(GTK_OBJECT(window));
> 	}
> 	gtk_main();
> 	return 0;
> }
> -------
> 
>  Why libgtk2 doesn't free memory from destroyed window in each loop
>  iteration? I think this problem is an important bug, so I label it. I
>  have an application that creates and destroys windows constantly, and
>  with this bug, it eats all memory and swap, slowing system until
>  freeze.

That code is buggy.. If you read the gtk documentation you'll see that
gtk_object_destroy sends out the destroy signal, which will eventually lead to
the destruction of the object. But you never give it the chance to actually
process the events. 

  Sjoerd
-- 
Where it is a duty to worship the sun it is pretty sure to be a crime to
examine the laws of heat.
		-- Christopher Morley