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 _______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
