GNOME Bugzilla – Bug 559240
program gets bigger and bigger
Last modified: 2008-11-04 09:40:01 UTC
Please describe the problem: when you run this program, it just keeps getting bigger: /* gcc -Wall -g test.c -o test2 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` */ #include <stdio.h> #include <stdlib.h> #include <gtk/gtk.h> GtkWidget *entry; GtkWidget *vbox; void do_it(){ GList *iter; GList *original_iter; iter = original_iter = gtk_container_get_children (GTK_CONTAINER (vbox)); while(iter){ GtkWidget *child; child = iter->data; iter = iter->next; gtk_container_remove(GTK_CONTAINER(vbox),child); } g_list_free(original_iter); int i; for( i = 0 ; i < 2000 ; i++){ entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); } } void do_it_many_times (){ int i; for(i = 0 ; i< 10000; i++){ do_it(); } } guint test_function(gpointer data){ do_it_many_times(); return 0; } int main( int argc, char *argv[] ) { int time_interval = 3000; GtkWidget *window; gtk_init (&argc, &argv); /* create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); gtk_window_set_title (GTK_WINDOW (window), "GTK Entry"); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect_swapped (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_widget_destroy), G_OBJECT (window)); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); g_timeout_add(time_interval,(GSourceFunc) test_function,0); gtk_widget_show (window); gtk_main(); return 0; } Steps to reproduce: 1. compile 2. run 3. Actual results: the program keeps getting bigger Expected results: the program doesn't keep getting bigger Does this happen every time? yes Other information: valgrind doesn't show much, related (but somewhat different) from 558594. The problem is much clearer with this program.
Just attach the new test program to bug #558594 then (as a single source file), don't file a new bug. *** This bug has been marked as a duplicate of 558594 ***