I will try, reading the comment on git it seams a problem introduced in
vala 0.23.1 but I have test also vala-0.22 and it have the same problem.


2014/1/4 Luca Bruno <[email protected]>

> I've just fixed the bug in vala git master, can you check?
> Commit 550b107896
>
>
> On Sat, Jan 4, 2014 at 7:56 PM, Luca Bruno <[email protected]> wrote:
>
>> Please report a bug at bugzilla.gnome.org .
>> So, using "o" in the lambda seems to be the problem.
>>
>>
>> On Sat, Jan 4, 2014 at 7:39 PM, Michele Dionisio <
>> [email protected]> wrote:
>>
>>> Hi, I'm new in this mailing list and quite new in vala programming.
>>>
>>> I have a big software that somethime leak objct. Now I have replicate the
>>> issue with a small code:
>>>
>>>
>>> ############################################################################
>>>     class Pippo: Object {
>>>         public async void foo () {
>>>             Object o = new Object ();
>>>             stdout.printf("out-- %u\n",o.ref_count);
>>>             stdout.printf("this -- %u\n",this.ref_count);
>>>
>>>             SourceFunc f = () => {
>>>                 stdout.printf("infunc-- %u\n",o.ref_count);
>>>                 stdout.printf("in this -- %u\n",this.ref_count);
>>>                 //this.unref();
>>>                 stdout.printf("in this -- %u\n",this.ref_count);
>>>                 stdout.printf("end function f\n");
>>>                 return false;
>>>             };
>>>             GLib.Idle.add( (owned) f );
>>>
>>>             stdout.printf("end function foo\n");
>>>         }
>>>
>>>         ~Pippo() {
>>>             stdout.printf("destroy pippo\n");
>>>         }
>>>     }
>>>
>>>     void main() {
>>>         Pippo ? tmp = new Pippo();
>>>
>>>         tmp.foo.begin();
>>>
>>>         MainLoop loop = new MainLoop ();
>>>
>>>         GLib.Timeout.add(1000, () => {stdout.printf("timeout1\n"); tmp =
>>> null; return false;});
>>>
>>>         GLib.Timeout.add(2000, () => {stdout.printf("timeout2\n");
>>> loop.quit(); return false;});
>>>
>>>
>>>         loop.run ();
>>> }
>>>
>>>
>>> ############################################################################
>>>
>>> If in the function
>>> SourceFunc f
>>>
>>> there is any reference to any variable of foo or to any object of this we
>>> have the reference counting of this increase.
>>>
>>> and so after timeout1 the object tmp is not destroy. (And there is no
>>> reference on it)
>>>
>>> The only way to fix the issue is to manually decrease the reference of
>>> this. But this is a big workaraound.
>>>
>>> Someone have any idea where is my fault or if there is a bug in vala
>>> itself?
>>>
>>> regards
>>> _______________________________________________
>>> vala-list mailing list
>>> [email protected]
>>> https://mail.gnome.org/mailman/listinfo/vala-list
>>>
>>
>>
>>
>> --
>> www.debian.org - The Universal Operating System
>>
>
>
>
> --
> www.debian.org - The Universal Operating System
>
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to