Go 1.5
Ola Fosheim Grøstad via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sat Sep 19 11:20:14 PDT 2015
On Saturday, 19 September 2015 at 17:56:23 UTC, thedeemon wrote:
> Yes, good point. One should keep root ranges small too.
> If we carefully use addRoot() and addRange() for data directly
> pointing to GC heap I think we don't need to let GC scan
> everything that can lead to this data. This is error-prone in
> general, of course.
Yes, it is error prone when the project grows over time. And even
if it looks like it is working one may forget to remove the
addRoot() and then we have a leak. Move semantics could help of
course (addRoot in constructor).
But it also makes the transition between GC/non-GC slower. E.g.
as long as you keep a scanned pointer on the stack then addRoot()
isn't needed. As long as you know that the object remains
included in the GC graph, you also don't need addRoot().
But compiler support is needed to ensure that that either the GC
graph remains connected or that the pointer actually is pushed to
the stack before the object is collected and the stack is
scanned. Lots of details that must be right.
I'm not sure if the current collector scans all registers, or
just scans the stack? If it only scans the stack then you need to
lock out the GC collection process between obtaining a pointer
and pushing the pointer on the stack or adding the root.
More information about the Digitalmars-d-announce
mailing list