[RFC]Proposal for better garbage collection

Sean Kelly sean at invisibleduck.org
Thu Feb 23 00:08:46 PST 2012

On Feb 22, 2012, at 8:07 PM, "Martin Nowak" <dawg at dawgfoto.de> wrote:

>> 4) Thread local / global memory
>> A callback into the runtime needs to happen in the following cases:
>> - a __gshared variable is assigned
>> - a reference / pointer is casted to immutable
>> - a reference / pointer is casted to shared
>> void _d_castToGlobalMem(void* ptr);
>> This can be used by the GC to keep thread local pools of memory and move a memory block to a global memory pool as soon as it is needed there.
> If we'd want per-thread mark/sweeping then shared memory must never own
> unshared memory. I think this could be done using a separate allocator for
> shared/immutable data. For casts this would require a transitive move of the
> data or it'd need to be prohibited.

Casting to/from shared needs a bit more logic anyway, so the proper thread finalizes unshared objects. Casting away shared clears the block's owner and vice versa. Nice perk to this is casting away shared could then detect a sharing violation if a block already has another owner. 

More information about the Digitalmars-d mailing list