std.allocator: primitives for helping GC

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Thu May 1 00:43:37 PDT 2014


01-May-2014 08:05, Andrei Alexandrescu пишет:
> So far allocators have been quite GC-agnostic; deallocation would be
> needed for each allocation, and there was little structure to help tracing.
>
> The primitive resolveInternalPointer has made a step toward more precise
> structuring of heaps, and now it's time to look at some real GC helpers.
>
> These are markAllAsUnused, markAsUsed, and doneMarking. Find their
> description here:
>
> http://erdani.com/d/phobos-prerelease/std_allocator.html
>
> There are a few proof of concept implementations here:
>
> https://github.com/andralex/phobos/blob/allocator/std/allocator.d
>
> The basic idea is that the GC would initiate a collection by calling
> markAllAsUnused. That would cause the underlying untyped allocator to
> softly mark all memory as free, but without actually messing it up.
> (Many allocators are capable of implementing such a primitive cheaply.)

It would be interesting to define where GC sits and how it integrates
with allocators to begin with. Given that currently GCAllocator is 
mentioned
somewhere at the bottom of heap layers I'm really at loss about how 
these helpers fit into the picture.

> Then, the GC would trace objects starting from roots. Whenever it finds
> a used pointer, it would mark the corresponding memory as allocated by
> using markAsUsed, effectively undoing the soft freeing for it.


How GC determines which allocator an object belongs to ?



-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list