[Vala] The behaviour of G.List and other containers.



First of all, I have to admit that I have a problem dealing with
automatic memory management, so this questions might sound a bit
stupid for some... sorry :)

I really like the idea of Vala, but I always get to the same problem:
I'm productive enough in C + GObject to spend time with some of the
subtleties of Vala's memory management system, that is, although I
would like to use it... after I spend a few minutes trying to wrap my
head around the memory management system I usually fall back to
writing the code in C as I am used to.

This time I decided I'd give it a longer try. So I decided to try
asking here first so I don't get driven out by my short patience :)

Well, enough babbling. The question is:

What is the correct way to deal with the assisted memory management
and Containers, such as the G.List ? I noticed that whenever I add
something to the list, it gets automatically ref()ed, but it seems I
can't get it to automatically unref() it. Is this the intended
behaviour ? Am I doing something stupid ? Or is it just that I am
supposed to rely on automatic ref()ing and then unref() by myself
(this last option I believe is a bit odd, though) ?

I didn't quite test, but I suppose the same behaviour is replicated
across the other glib containers, as they all share the same style of
API.

I'm sorry for this long post for something so simple, but I felt like
I needed to explain why such a stupid question is being posted :)

Regards,
Alexandre Moreira.

PS: I just noticed the documentation project on the page and, as soon
as I get the grip with this memory management stuff I feel I could
give you guys a bit of help there. I am programming C# at work right
now, although I'm not exactly a Pro (just filling a gap where a C#
Programmer was needed and I was known for learning languages fast
enough to finish the job). I believe this can make my learning of Vala
faster and then help me help the rest of the community.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]