GC of const/immutable reference graphs
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 13 08:48:34 PDT 2016
On Tuesday, 13 September 2016 at 15:27:23 UTC, John Colvin wrote:
> For the following, lifetimeEnd(x) is the time of freeing of x.
>
> Given a reference graph and an const/immutable node n, all
> nodes reachable via n (let's call them Q(n)) must also be
> const/immutable, as per the rules of D's type system.
>
> In order to avoid dangling pointers:
> For all q in Q(n), lifetimeEnd(q) >= lifetimeEnd(n)
>
> Therefore, there is never any need for the GC to mark or sweep
> anything in Q(n) during the lifetime of n.
>
> Does the GC take advantage of this in some way to reduce
> collection times?
I am pretty sure it does not.
More information about the Digitalmars-d
mailing list