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 623543 - Memory leak when using GLib.Value with GLib.Object classes
Memory leak when using GLib.Value with GLib.Object classes
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.9.x
Other All
: Urgent blocker
: ---
Assigned To: Vala maintainers
Vala maintainers
wrong-code test-case
: 624494 626551 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-07-04 19:17 UTC by Artyom
Modified: 2017-03-25 14:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Artyom 2010-07-04 19:17:31 UTC
Following Code causes memory leak.
In first case when value is not-temporary object Foo is managed correctly,
however, when a value object is created on the fly the reference counter
is increased once more.

So expected output should be:

Ctor
Dtor
----
Ctor
Dtor

But getting only

Ctor
Dtor
----
Ctor


Code:


        class Foo : Object
        {
                public Foo() {
                        stdout.printf("Ctor\n");
                }
                ~Foo() {
                         stdout.printf("Dtor\n");
                }
        }

        void foo(Value v)
        {
        }


        static int main (string[] args)
        {
                /// Ok
                {
                        Foo f=new Foo();
                        Value v=f;
                        foo(v);
                }
                stdout.printf("--------\n");
                /// Error
                {
                        Foo f=new Foo();
                        foo(f);
                }
                return 0;
        }
Comment 1 Artyom 2010-07-07 19:38:24 UTC
Any comments? Is it a bug at all?
Comment 2 Evan Nemerson 2010-08-25 07:42:38 UTC
*** Bug 626551 has been marked as a duplicate of this bug. ***
Comment 3 Jürg Billeter 2010-09-09 17:55:09 UTC
commit 885588582e4c8423fcfaabf9f5315e457f6b9d14
Author: Jürg Billeter <j@bitron.ch>
Date:   Thu Sep 9 19:53:54 2010 +0200

    codegen: Fix GValue memory leak after boxing
    
    Fixes bug 623543.
Comment 4 Jürg Billeter 2010-10-06 18:59:20 UTC
*** Bug 624494 has been marked as a duplicate of this bug. ***