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 630987 - Delegates may create reference cycles
Delegates may create reference cycles
Status: RESOLVED DUPLICATE of bug 624624
Product: vala
Classification: Core
Component: Delegates
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-09-30 07:42 UTC by Mikkel Kamstrup Erlandsen
Modified: 2010-10-16 11:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case to reproduce the bug (1.23 KB, text/x-vala)
2010-09-30 07:42 UTC, Mikkel Kamstrup Erlandsen
Details

Description Mikkel Kamstrup Erlandsen 2010-09-30 07:42:11 UTC
Created attachment 171409 [details]
Test case to reproduce the bug

A GObject derived class will do a g_object_ref(self) in it's constructor if you assign a lambda or non-static instance method to a delegate member of the class. This causes the constructor to return an object with refcount > 1.

See attachment for a test case that asserts because of the described leaks. It exercises three cases:

 0) Static methods (no leak)
 1) Lambda (leak)
 2) Instance methods (leak)
Comment 1 Jürg Billeter 2010-10-16 08:29:49 UTC
This is not a reference leak and it's also not an issue per se if a constructor returns an object with a reference count > 1.

The real and more general issue is that it's very easy to create reference cycles when using delegates without an obvious way to avoid them.
Comment 2 Jürg Billeter 2010-10-16 11:51:37 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

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