GNOME Bugzilla – Bug 691606
MemoryLeak when creating Gio::FileInputStream
Last modified: 2013-01-14 18:54:54 UTC
Created attachment 233302 [details] All fiels needed to reproduce this bug I've found a memory Leak in Giomm 2.4 64-Bit. The glibmm-version is the version one can install from Synaptics in Linux Mint 14. Minimum Example: #include <gtkmm.h> #include <iostream> int main(int argc, char** argv) { Gtk::Main main(argc, argv); try { Glib::RefPtr<Gio::File> file = Gio::File::create_for_path("/path/to/existing/file"); while(1) { Glib::RefPtr<Gio::FileInputStream> stream = file->read(); stream->close(); stream.clear(); } }catch(const Glib::Exception& e) { std::cout<<"Exception:\n"<<e.what()<<"\n"; return 23; } return 0; } "/path/to/existing/file" must be a path to an existing file ;) Just run this sample and watch in your System Monitor/Taskmanager the usage of memory raise. I have attached all files needed to reproduce this bug: repro.cpp the minimum example (exactly the same code as above) compile.sh a shellscript compiling the code
File glibmm/gio/src/file.hg contains too many 'refreturn'. Gio::File::read() is one of many methods that has a refreturn in its _WRAP_METHOD although the description of the corresponding glib function says "Free the returned object with g_object_unref()." I'll fix that.
Fixed in the master branch with this commit: http://git.gnome.org/browse/glibmm/commit/?id=16269fd1c0c53f77e1365c5cc8a2ea9ddefe9fa0 and in the glibmm-2-34 branch with this commit: http://git.gnome.org/browse/glibmm/commit/?h=glibmm-2-34&id=855c956205afd31a2b141c22fa2986580991c41e