Re: [Vala] reference management.
- From: "Alexandre Moreira" <alexandream gmail com>
- To: vala paldo org
- Subject: Re: [Vala] reference management.
- Date: Tue, 20 Mar 2007 16:29:09 -0300
On 3/20/07, Jürg Billeter <j bitron ch> wrote:
On Die, 2007-03-20 at 10:17 -0300, Alexandre Moreira wrote:
> I think it would be just great to allow the user to specify an "expert
> mode" and allow him to do the ref unref by himself (just like GObject
> does, giving G.Object a method to do each action) and, at most, having
> the auto-unref-local-variables-unless-specified-otherwise.
>
> Basically it would mean the addition of the ref/unref methods and an
> option to set all references to weak.
You can disable automatic memory management in vala by using the
--disable-memory-management command-line option. I've also added ref and
unref methods to GLib.Object, so you can leak as much memory as you want
now ;)
Yay! Gee... I have to say, I was affraid that memory management would
lead me to leave Vala, and now you came with everything I need... once
more! I really like this project :)
> I know *I* (and I know it doesn't mean much) would prefer working like
> this. The more automatic behavior the more unpredictible or complex
> are the rules to define "how each case is handled" and I believe these
> unpredictible or complex rules create more of a mental effort to the
> programmer than the activity of handling its own references.
The unpredictability / complex behavior is the reason why I've just
disabled the heuristic in Vala SVN; local variables also default to
strong references. So the rules are now very simple and you can use weak
wherever you want to improve performance if you understand reference
handling of GObjects. I believe that using automatic memory management
will lead to easier readable code and less bugs, so I won't recommend to
use the --disable-memory-management option. If you still want to work
with disabled automatic memory management, I'd be interested in further
explanations why, to possibly improve the default behavior further.
Well, as long as I can declare my own weak / strong variables and do
the reference counting manually on a per-case basis, everything is
gonna be great. I like the way Vala does its (what I like to call)
"assisted" memory management (as opposed to automatic), but sometimes
it just feels like the code is more easily understandable by
explicitly doing stuff.
I will have to test a bit, and start porting my C code to Vala to see
how will it be to work with a mix of default strong references and
weak in a per-case basis.
By the way, how are GIOChannels handled by assisted memory management
? I have a class that I intend to port from C to Vala and I deal with
a few Channels in it.
Best regards, and keep up the great work guys... it simply rules!
Alexandre Moreira.
PS: Please, if you ever decide on going to a full garbage collector,
please allow me and other memory leakers to handle their own
references and frees and deletes and whatever... even if you quit this
"auto-dereference" stuff to substitute it for the garbage collector,
being able to fall back to full-manual memory management would keep me
using Vala happily :)
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]