Thought on limiting scope of GC

Jerry jlquinn at optonline.net
Fri Feb 14 08:10:49 PST 2014


"Paulo Pinto" <pjmlp at progtools.org> writes:

> On Friday, 14 February 2014 at 04:41:43 UTC, Jerry wrote:
>> My thought is to have something like the following:
>>
>> GC.track();
>> auto obj = allocateStuff();
>> GC.cleanup(obj);
>>
>> The idea here is that track() tells GC to explicitly track all objects
>> created from that point until the cleanup call.  The cleanup() call
>> tells gc to limit its collection to those objects allocated since the
>> track() call.  The obj parameter tells gc to consider obj live.
>>
>> This way, you can avoid tracking everything that may get created, but
>> you can limit how much work gets done.
>
> How do imagine it to work in multi-core programs? Does it only track thread
> local allocations?

I think this can be handled by storing the thread that requests
tracking, and then each allocation is tracked if it's done from the same
thread that requested tracking.  Then cleanup just considers the objects
that were tracked.


More information about the Digitalmars-d mailing list