Strictly speaking I'm talking about a gtkmm app but since gtkmm is mostly just 
a wrapper around gtk+ maybe I should start here.

Some time ago I built a small gtkmm app using gtk-win32 and Microsoft Visual 
C++.  MSVC has some pretty sophisticated leak detection tools and in the past, 
I've tended to turn them on for my MSVC builds.  So a week or two ago I enabled 
leak detection for my gtkmm app and was a bit disappointed at how much memory 
was leaking.

At first I assumed the leaks would be my fault but a week of inspecting my code 
revealed nothing.  Eventually I boiled the situation down to the following 
minimal code sample:-

#include <gtkmm.h>

int main (int argc, char *argv[])
{
      Gtk::Main *app = new Gtk::Main (&argc, &argv);

      delete app;

      return 0;
}

The above code causes hundreds of memory leaks.  I'd be happy to try and trace 
them but I know that gtk+ has been built by better programmers than me - so if 
memory is leaking (certainly on this scale) it's probably for a good reason.  
This code results in identical leaks:-

#include <gtkmm.h>

int main (int argc, char *argv[])
{
      Gtk::Main  app(&argc, &argv);

      return 0;
}

In both cases, not creating the Gtk::Main object completely eliminates the 
memory leaks, so I can be reasonably confident they're coming from gtk+ or 
gtkmm.   If this comes as a big surprise to the gtk+ developers I'd be happy to 
take a closer look but I figured there might be some reason for the leaks 
that's already obvious to the development team but not to me.  I don't want to 
waste too much time on this if it's expected behaviour.

John
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to