Re: another memory leak
- From: Yu Feng <rainwoodman gmail com>
- To: Jacques Le Normand <rathereasy gmail com>
- Cc: gtk-devel-list gnome org, gtk-app-devel-list gnome org
- Subject: Re: another memory leak
- Date: Thu, 30 Oct 2008 14:36:34 -0400
On Wed, 2008-10-29 at 22:08 -0400, Jacques Le Normand wrote:
> Hello list,
> thank you for helping me to solve my previous post, which found that I
> had a memory leak. The solution was to remove uim (universal input
> method).
Would you say more about the solution in the list? I am also interested
in it but don't know why there is a leak.
> I have a new memory leak problem. This one creates and removes 2000
> text entries every 100ms. I've had top showing 64 megs resident after
> 5 minutes (and no sign of stopping).
> If anyone could run the code to see if they get a memory leak (and
> post the result) it would be great!
> If anyone could shed some light on the problem, even better!
> cheers
> --Jacques
>
> (and now the code...)
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <gtk/gtk.h>
>
>
> GtkWidget *entry;
> GtkWidget *vbox;
>
> guint test_function(gpointer data){
> 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);
> }
> return 1;
> }
>
> int main( int argc,
> char *argv[] )
> {
> int time_interval = 100;
> 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;
> }
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]