RFC: safe ref counting

Steven Schveighoffer schveiguy at gmail.com
Sat May 2 20:34:48 UTC 2020


On 5/2/20 2:38 PM, Jonathan M Davis wrote:
> On Saturday, May 2, 2020 12:16:13 PM MDT Steven Schveighoffer via
> Digitalmars-d wrote:
>> I like the plan of letting the GC ensure the memory is always valid. I'm
>> just not sure about the problem of cycles. That's the one place this
>> might fall down.
> 
> As I understand it, as long as nothing that the program still has access to
> refers to the objects with circular references, the cycle won't be a
> problem, and the GC will be able to collect them. I recall Andrei talking in
> the past about having reference counting which did basically what you're
> describing with the GC being left to handle the cycles.

This is different. I'm pinning the blocks so they won't be collected 
until all "appropriate" (e.g. "counted") references are no more.

Essentially, what I want is ref counting for resource management, but 
instead of freeing the memory, I'm releasing it for the GC to clean up.

So there is definitely the possibility of cycles.

-Steve


More information about the Digitalmars-d mailing list