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 624494 - memory leaks with Value?
memory leaks with Value?
Status: RESOLVED DUPLICATE of bug 623543
Product: vala
Classification: Core
Component: Code Generator: GObject
0.9.x
Other Windows
: Normal critical
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-07-15 21:18 UTC by Olivier Chalouhi
Modified: 2010-10-06 18:59 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Olivier Chalouhi 2010-07-15 21:18:52 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);
    }
  }
}
Comment 1 Olivier Chalouhi 2010-07-15 23:05:37 UTC
The memory leak also happens when unboxing the Glib.Value without going through a temp variable.
Comment 2 Evan Nemerson 2010-08-25 07:42:56 UTC
It looks like the first problem has been fixed, and I think the second one is a duplicate of bug #623543.
Comment 3 Jürg Billeter 2010-10-06 18:59:20 UTC
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 ***