After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686205 - Calls to methods with caller allocated boxed out arguments leak memory
Calls to methods with caller allocated boxed out arguments leak memory
Status: RESOLVED DUPLICATE of bug 691501
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-10-16 07:08 UTC by Simon Feltman
Modified: 2013-01-11 22:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon Feltman 2012-10-16 07:08:35 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.
Comment 1 Simon Feltman 2013-01-11 22:08:05 UTC

*** This bug has been marked as a duplicate of bug 691501 ***