Re: Memory Leak when using GnomeDialog




David Haraburda <dharaburda@eversoft.com> writes: 
> I have a memory leak in my GNOME application that I am having a hard
> time tracking down.  I have connected my callback function to a menu
> item click, using the GnomeUIInfo structures. For testing purposes, I've
> commented out everything but two lines of code in my callback:
>

OK I did some memprof/printf investigation:

 - the dialogs themselves are definitely getting destroyed
 - if you have the Imlib cache turned on, then creating/destroying
   100 dialogs uses nearly 512K. This is supposed to be turned 
   off by default, but try imlib_config and turning off the cache
   to be sure. Imlib's cache is totally broken
 - GnomePixmap still has a mild memory issue with the cache off, 
   again the expanding memory is coming from Imlib it looks like
   but I haven't figured it out yet
 - memprof doesn't actually report any leaks in either case, 
   there are pointers to this memory still sitting around
   somewhere (possibly in unused memory garbage, though that 
   seems unlikely when creating/destroying 100 dialogs)
   (of course this makes sense for the broken cache issue)

I'm rebuilding gnome-libs and will try some fixes.
  
Havoc
   

Here is a test program for anyone who's interested:

#include <gnome.h>
#include <stdio.h>

int main(int argc,char** argv)
{

  GtkWidget* w;
  int i;

  g_malloc(20);
  
  gnome_init("blah", "0.1", argc, argv);

  i = 0;
  while (i < 100)
    {
#if 1
      w = gnome_dialog_new("Create New Report",
                           GNOME_STOCK_BUTTON_OK,
                           GNOME_STOCK_BUTTON_CANCEL,
                           NULL);

      printf("rc %u\n",  GTK_OBJECT(w)->ref_count);
      
      gnome_dialog_close(GNOME_DIALOG(w));
#else
      w = gtk_button_new();

      printf("rc %u\n",  GTK_OBJECT(w)->ref_count);
      
      gtk_widget_destroy(w);
#endif
      
      if (GTK_OBJECT_DESTROYED(w))
        printf("yes %u\n",  GTK_OBJECT(w)->ref_count);
      else
        printf("no %u\n", GTK_OBJECT(w)->ref_count);
      
      ++i;
    }

  gtk_main();
  
  return 0;
}



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