Memory leak in gtk+ ??




The following bug report was reported to the GtkAda team (of course, it was in
Ada at the time, the code below is a quick translation).

When you run and compile the code below, the application uses more and more
memory.
This problem does not appear if we get rid of the "gtk_show" statements, in
which case the memory usage remains at the same level during the life of the
application (this is just what we see with top, nothing more elaborate).

I have tried to use the g_mem_profile function, but apparently it only gives
what was allocated, not what was not freed. I also did a difference between
the output when creating 10 and 500 widgets, but no obvious problem there, so
I don't really know.

Any hint/help/fix would be appreciated. I am willing to help in fixing that,
but I don't really know where to go from here.

Emmanuel



Here is the code:


#include <gtk/gtk.h>

int
main (int argc, char** argv)
{
  int i;
  GtkWidget* win;
  GtkObject* adj;
  GtkWidget* scale;
  
  gtk_init (&argc, &argv);

  for (i = 1; i < 500; i++) {
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    adj = gtk_adjustment_new (1.0, 0.0, 5.0, 0.5, 1.0, 2.0);
    scale = gtk_hscale_new (GTK_ADJUSTMENT (adj));

    gtk_container_add (GTK_CONTAINER (win), scale);
    gtk_widget_show (scale);
    gtk_widget_show (win);
    gtk_widget_destroy (win);
  }

  return 0;
}
     



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