GNOME Bugzilla – Bug 688137
GValue's holding boxed and gobject types leak references
Last modified: 2012-11-12 07:24:32 UTC
It looks as though GObject.Value is an introspected type with gi.Boxed and gobject.GBoxed as bases. The destruction of GValue's created in python and set to hold a boxed or object type will leak that reference after the GValue is collected. An override could be added implementing __del__ which makes a call to "unset" to fix the leak. However, this might not be desired in the case of a pointer to a GValue passed as a parameter to a python vfunc with the transfer != GI_TRANSFER_EVERYTHING. Or rather we could expose the "free_on_dealloc" static property of gobject.GBoxed and check that within the __del__. For example: class Value(GObjectModule.Value): def __del__(self): if self._free_on_dealloc: self.unset() Value = override(Value)
Created attachment 228747 [details] [review] Add expectantly failing unittests for GValue boxed/object leaks
Created attachment 228752 [details] [review] Fix leaks with GValue's holding boxed and object types Expose read access to PyGIBoxed.free_on_dealloc. Add GObject.Value.__del__ override and call unset() to correctly free reference counts.
Comment on attachment 228747 [details] [review] Add expectantly failing unittests for GValue boxed/object leaks Thanks for these! Please go ahead. Can you please drop the apostrophe in "Fix leaks with GValue's holding boxed and object types"?