Re: [Vala] Reference counting



Кутейников Дмитрий wrote:
How does Vala count references for arrays and strings? They are not
subclasses of GLib.Object and don't contain any special fields.

Hello,

I think Vala doesn't perform reference counting for things like strings,
arrays and structures at all. You have three options handling these objects:

  * Do nothing special. Instead of inserting code to increment and
    decrement reference counts, Vala will insert code to copy and
    destroy the objects automatically. This is safe, but may be slow
    for large objects. Also multiple simultaneous references to the
    "same" thing will not really point to the same memory address but
    to multiple copies.

  * Transfer ownership manually which is safe and fast, but cannot be
    applied when multiple simultaneous references to the same object are
    required.

  * Use weak references, which is unsafe but fast and can be used with
    multiple simultaneous references to the same thing.

cu,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.



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