Shared keyword and the GC?

Sean Kelly sean at invisibleduck.org
Thu Oct 18 13:29:23 PDT 2012


On Oct 18, 2012, at 12:22 PM, Jacob Carlborg <doob at me.com> wrote:

> On 2012-10-18 20:54, Sean Kelly wrote:
> 
>> And back down to a local pool when shared is cast away.  Assuming the block is even movable.  I agree that this would be the most efficient use of memory, but I don't know that it's feasible.
> 
> You said the thread local heap would be merged with the global on thread termination. How is that different?
> 
> Alternative it could stay in the global heap. I mean, not many variables should be "shared" and even fewer should be casted back and forth.

It's different in that a variable's address never actually changes.  When a thread completes it hands all of its pools to the shared allocator, and then per-thread allocators request free pools from the shared allocator before going to the OS.  This is basically how the HOARD allocator works.


More information about the Digitalmars-d mailing list