precise GC

Rainer Schuetze r.sagitario at gmx.de
Tue Mar 5 20:50:34 UTC 2019



On 04/03/2019 12:12, 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?
> 2) precise-GC will NOT scan it at all. is it true?

As Adam pointed out, this memory block is neither scanned by the default
GC nor the precise GC because they don't contain any references.

> 
> 3) closures: do the closures have any internal types that helps to GC or
> are they (full closure memory block) scanned as in the conservative mode?

No type information is generated for closures by the compiler, so these
are always scanned conservatively.

> 
> 4) associative arrays:
> SomeTypeWithRefsToClasses[string]
> any pair will be allocated at some memory block [hash, key, value] as I
> imagine.
> Will be precise-GC scan at every pair block only some fields of
> SomeTypeWithRefsToClasses or full [pair-block]?
> will be scanned string-key memory block: span-struct and\or chars data?

associative arrays use allocations containing both key and value. These
are scanned as if they are combined to a struct, so only actual pointers
with the precise GC, semi-precisely (as Adam put it) with the default GC.


More information about the Digitalmars-d-learn mailing list