A bug in my code

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Sep 8 05:38:48 PDT 2008


On Mon, Sep 8, 2008 at 6:09 AM, Sergey Gromov <snake.scaly at gmail.com> wrote:
> Jarrett Billingsley <jarrett.billingsley at gmail.com> wrote:
>> On Sun, Sep 7, 2008 at 12:59 PM, bearophile <bearophileHUGS at lycos.com> wrote:
>> > Uhm... I don't understand fully: do you mean roots don't become deleted
>> > when they have nothing that points to them?
>> > The docs say:
>> > "Roots are references to memory allocated by the collector that are
>> > maintained in memory outside the collector pool."
>>
>> I think what you should be using instead is addRange.  addRoot more or
>> less tells the GC "never collect memory referenced by this pointer",
>> but it doesn't actually scan the memory _pointed to_ by the roots for
>> pointers.
>
> This just cannot be.  A root is a place where a tree of live memory
> objects is grafted.  That's why it is called a "root".  A memory block
> pointed to by a root is kept alive and, obviously, scanned for pointers
> to other memory blocks if it hasPointers().
>
> There's a problem with addRoot() that, if the memory block is re-
> allocated, the old root stops serving its purpose.  In that case you
> need to remove an old root and add the new one, pointing into the re-
> allocated block.
>

Let's put some words in this one!

You're right, I'm sorry for spreading misinformation.


More information about the Digitalmars-d-learn mailing list