GNOME Bugzilla – Bug 686205
Calls to methods with caller allocated boxed out arguments leak memory
Last modified: 2013-01-11 22:08:05 UTC
This can be observed by watching the memory of a python console running the following: from gi.repository import Gtk model = Gtk.ListStore(int) model.append(0) while True: model.get_iter(0) The issue is when calling get_iter, pygobject will allocate new memory for the iter struct which is copied into by the vfunc marshaling of the iter created in do_get_iter. do_get_iter no longer leaks references as was fixed here: https://bugzilla.gnome.org/show_bug.cgi?id=686140 The call to get_iter creates memory for the struct, makes the ffi call, and finally adds the struct pointer to a PyGBoxed wrapper with free_on_dealloc set to 0. This means it will not free the memory it allocated when there are no more refs to the wrapper. This is a memory leak, not just a reference leak. The problematic part of the code is: gi/pygi-marshal-to-py.c : _pygi_marshal_to_py_interface_struct where the creation of a PyGBoxed wrapper by _pygi_boxed_new uses "arg_cache->transfer == GI_TRANSFER_EVERYTHING" as it argument for free_on_dealloc. This could probably check if the argument is caller allocated either in addition or as a replacement to that logic. But the full implication of changing that needs to be studied in more detail.
*** This bug has been marked as a duplicate of bug 691501 ***