GNOME Bugzilla – Bug 624494
memory leaks with Value?
Last modified: 2010-10-06 18:59:20 UTC
Here's a short snippet which showcases two memory leaks : public class Holder : Object { Value? val; public Holder(Value? val) { this.val = val; } //In the absence of this explicit destructor //the value doesn't get unset, and leads to memory being leaked ~Holder() { if(val != null) { val.unset(); } } } public class Test : Object { public static void main(string[] args) { Holder val; while(true) { StringBuilder sb = new StringBuilder(); sb.append_unichar(' '); //In the absence of this temporary variable the GValue doesn't get freed, // and leads to a memory leak //eg : val = new Holder(sb.str); would leak. GLib.Value gval = sb.str; val = new Holder(gval); } } }
The memory leak also happens when unboxing the Glib.Value without going through a temp variable.
It looks like the first problem has been fixed, and I think the second one is a duplicate of bug #623543.
Thanks for taking the time to report this bug. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade. *** This bug has been marked as a duplicate of bug 623543 ***