why allocators are not discussed here

Robert Schadek realburner at gmx.de
Wed Jun 26 07:30:50 PDT 2013


>> Imagine we have two delegates:
>>
>> void* delegate(size_t);  // this one allocs
>> void delegate(void*);    // this one frees
>>
>> you pass both to a function that constructs you object. The first is
>> used for allocation the
>> memory, the second gets attached to the TypeInfo and is used by the gc
>> to free
>> the object.
>
> Then it's just GC but with an extra complication.
>
IMHO, not really, as the place you get the memory from is not managed by
the GC, or at least not
directly. The GC algorithm would see that there is a "free delegate"
attached to the object and would
use this to free the memory.

The same should hold true for calling GC.free.

Or are you talking about ref counting and such?


More information about the Digitalmars-d mailing list