another memory leak

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).
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!

(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));
    GtkWidget *child;
    child = iter->data;
    iter  = iter->next;

  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);


    return 0;

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