Shared keyword and the GC?

deadalnix deadalnix at gmail.com
Mon Oct 22 14:19:53 PDT 2012


Le 22/10/2012 22:44, Andrei Alexandrescu a écrit :
> On 10/22/12 3:16 PM, Jacob Carlborg wrote:
>> On 2012-10-22 19:44, Sean Kelly wrote:
>>
>>> Blocks flagged as shared would be completely ignored by the
>>> thread-local GC collection. Since shared data may never reference
>>> unshared data, that should avoid anything being collected that's still
>>> referenced. I hadn't thought about "immutable" though, which may turn
>>> out to be a problem.
>>
>> Funny thing, immutable was supposed to make it easier to do concurrency
>> programming.
>
> But not garbage collection.
>

OCmal's GC is one of the fastest GC ever made. And it is the case 
because it uses immutability to great benefice.

As immutable data can only refers to immutable data, I don't see a 
single problem here.

When collection shared and TL, you get a set of root pointer to 
immutable. All immutable can be collected from such set. All object 
allocated during the collection is supposed to be live.


More information about the Digitalmars-d mailing list