GC scan for pointers

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 9 07:50:43 PST 2016


On Wednesday, 9 March 2016 at 15:14:02 UTC, Gerald Jansen wrote:
> will the large memory blocks allocated for a, b and/or c 
> actually be scanned for pointers to GC-allocated memory during 
> a garbage collection? If so, why?

No. It knows that the type has no pointers in it, so it will not 
scan it for them.

If it was a struct with a pointer, it might be scanned though. Or 
static arrays of int on the stack will also be scanned, since the 
GC doesn't actually know much about local variables - it 
conservatively assumes anything on the stack might be a pointer.

But large arrays are rarely on the stack so I think it is an ok 
situation.

See the GC block attr flags:

http://dpldocs.info/experimental-docs/core.memory.GC.BlkAttr.html


More information about the Digitalmars-d-learn mailing list