GNOME Bugzilla – Bug 591003
Memory Leak in Gtk::Window
Last modified: 2009-08-07 09:53:38 UTC
Creating and destroying a Gtk::Window in a loop loses 3MB on each iteration as demonstrated by this tiny program. Since creating windows is a fundamental requirement in our application, this is depleting all of memory and swap, and finally crashing. #include <gtkmm.h> #include <iostream> using namespace std; class Win : public Gtk::Window { public: Win() { set_size_request(1024, 768); realize(); } ~Win() { cerr << "Destroying window" << endl; } }; int main(int argc, char* argv[]) { Gtk::Main App(argc, argv); // Initialize GTK+ while (true) { Win* w = new Win; if (Gtk::Main::events_pending()) Gtk::Main::iteration(); ::sleep(2); delete w; } exit (0); }
*** Bug 591000 has been marked as a duplicate of this bug. ***
I've let it run for 20~30 iterations and the memory usage always was 2.3MB. It never fluctuated. What version of gtkmm are you using? I am using 2.16 on Ubuntu 9.04 amd64.
I am running version 2.12 on a 32-bit Fedora FC9 on x86 using DirectFB 1.1.1 I have a suspicion that the leak is in the DirectFB back-end.
Yep - this turns out to be a problem in the DirectFB back-end. bug #533456 addresses this.
*** This bug has been marked as a duplicate of 533456 ***