On Thursday, 13 November 2014 at 22:12:22 UTC, deadalnix wrote:
You need a set of root from the TL heap. The trick being to
consider everything that is allocated AFTER you get the roots as
automatically alive (you'll collect this in the next collection
cycle).

That way, new allocated chunk that have reference in the TL heap
will be kept alive, even if you don't know about the roots.

You'll find plenty of information about the details if look into
GC for ML family languages.

Consider this:

    auto i = new immutable(int);
    immutable(int)* a, b;
    b = i;
    // GC kicks in here, scans `a` (== null)
    a = b;
    b = null;
    // GC goes on, scans `b` (== null)
    // => whoops, no reference to *i

Here, a and b are on the stack or in registers. They could also be on the TL heap.

Reply via email to