possible memory leak in gtk_label_set?



I've noticed this on both Solaris 2.6 and Red Hat 5.0, from both C
and Perl Gtk.  The best demo is to continually update the label in
a gtk_label widget via gtk_widget_set().  I've enclosed a small C
program to demonstrate this.

If you run the program, and watch its memory usage via top or ps,
the total process size grows by 4K every few seconds.

Any ideas?  I've had a brief look at gtklabel.c and I see nothing
*obviously* wrong.  I'll carry on looking anyway.  I'm going to 
enable the glib memory checking & profiling for a start.  I shall
report back when I know more...

----------------------------------------------------------------------

#include <gtk/gtk.h>

static int timer;

gint
timeout_cb (gpointer data)
{
  static int count = 0;
  char buffer[12];

  sprintf(buffer, "%d", count++);
  gtk_label_set(GTK_LABEL (data), buffer);

  return TRUE;
}


int
main(int argc, char **argv)
{
  GtkWidget *window, *label;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (window, "main window");
  gtk_widget_set_usize (window, 200, 200);

  label = gtk_label_new("label");

  gtk_container_add (GTK_CONTAINER (window), label);

  gtk_widget_show (label);
  gtk_widget_show (window);

  timer = gtk_timeout_add (100, (GtkFunction) timeout_cb, label);

  gtk_main ();

  return 0;
}

----------------------------------------------------------------------

-- 
Des Herriott
des@ops.netcom.net.uk



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