precise GC
Adam D. Ruppe
destructionator at gmail.com
Mon Mar 4 14:32:40 UTC 2019
On Monday, 4 March 2019 at 10:38:29 UTC, KnightMare wrote:
> For example, we have some rooted memory block as
> auto rooted = new long[1_000_000];
> 1) conservative-GC will scan it for false pointers every
> GC-cycle. is it true?
Well, conservative GC in general might, but D's GC would NOT.
D's old GC is arguably semi-precise. It would scan void[]
conservatively, anything that looks like a pointer is considered
maybe a pointer. But it would NOT scan blocks allocated as long[]
or ubyte[]. It would allocate those as NO_SCAN blocks.
The difference is in combination things, like the stack or
structs with static blocks.
struct {
int a;
void* b;
}
The old GC would treat that whole struct as potentially pointers,
both a and b. The new precise GC would know only b needs to be
scanned inside that struct.
The even bigger deal with precise is it also knows only b would
need to be changed if the pointer were to move - that's the big
gain precise is setting the groundwork for, to enable moving GC
optimizations.
More information about the Digitalmars-d-learn
mailing list