On Friday, 14 February 2014 at 04:41:43 UTC, Jerry wrote:
My thought is to have something like the following:
GC.track();
auto obj = allocateStuff();
GC.cleanup(obj);
The idea here is that track() tells GC to explicitly track all
objects
created from that point until the cleanup call. The cleanup()
call
tells gc to limit its collection to those objects allocated
since the
track() call. The obj parameter tells gc to consider obj live.
What if allocateStuff() writes address of some newly allocated
object to a field of some old object existing before GC.track()?
You can't just scan only objects created after GC.track(), this
might create dangling references in the "old generation".