The documentation of GC.addRoot() (mentioned by Simen), contains this
interesting piece of example code:

   // Also ensure that a moving collector does not relocate
   // the object.
   GC.setAttr(cast(void*)context, GC.BlkAttr.NO_MOVE);

Looks like we *already* have the way to pin objects to their current
memory location. (This compiles and is running without errors so far,
though I didn't try to look if it is actually doing something under
the hood -- which currently doesn't matter much, since the current GC
doesn't move objects).

(And yes, a GC.clrAttr() call does exist, too.)

LMB


On Sun, Jul 14, 2013 at 6:29 AM, Jacob Carlborg <d...@me.com> wrote:
> On 2013-07-13 20:53, Leandro Motta Barros wrote:
>>
>> Hey, thanks! This makes sense :-)
>>
>> Am I now wondering... how safe, portable and future proof would this
>> be? If some future version of D implements a garbage collector capable
>> of moving objects around the heap, I could get in trouble, right?
>
>
> Walter has always said that there's nothing in the language (D) that stops
> it from having moveable GC. In this case we would hope there would be way to
> pin objects.
>
> --
> /Jacob Carlborg

Reply via email to