Re: memory leak when destroying widgets

2008/10/27 Jacques Le Normand <rathereasy gmail com>:
> Hello list
> I have this short program that's leaking memory (according to top). Could
> someone tell me what I'm doing wrong?
> The program simply creates, packs and shows 100 gtk_entries and then
> destroys them at 400 ms intervals
> I appreciate any help you can give
> P.-S. I didn't know which list to send it to, so I sent it to both. If
> someone could tell me which of the two lists is more appropriate, I'll stop
> bothering the other one

I guess suspected leaks are a devel-issue...

> --Jacques
> ...and now, the program:
> /* 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 *vbox;
> GtkWidget *entry;
> guint test_function(gpointer data){
>   GList *iter;
>   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);
>   }

You are leaking the GList there.

I couldn't see anything else in valgrind, just the usual false alarm
from fontconfig caches.

Maybe freeing the GList fixes things for you too?

Kalle Vahlman, zuh iki fi
Powered by
Interesting stuff at

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