RCArray is unsafe

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 4 12:20:54 PST 2015


On Wednesday, 4 March 2015 at 10:49:06 UTC, Walter Bright wrote:
> On 3/4/2015 2:03 AM, deadalnix wrote:
>> A free list does not work as the data can be live.
>
> It is a "to free" list.
>

What I wanted to illustrate is that it is not a free list (which 
use the freed storage to maintain its state) as you cannot 
recycle storage.

>> You need to maintain metadata about allocation in
>> another structure.
>
> I don't see why.
>

Isn't it what the "to free" list is ?

>> Also you cannot free anything until all the refcount are to 0.
>
> Right.
>
>> This RC system will only cut it for short lived entities.
>
> Not a problem if they aren't constantly reassigning the value.

Having pool of object you recycle is a common strategy to reduce 
allocations when performance is critical. It is for instance 
incompatible with RC as proposed.


More information about the Digitalmars-d mailing list