GC scan for pointers

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 9 09:08:37 PST 2016


On Wed, 09 Mar 2016 15:50:43 +0000, Adam D. Ruppe wrote:
> Or static
> arrays of int on the stack will also be scanned, since the GC doesn't
> actually know much about local variables

It's especially tricky because compilers can reuse memory on the stack 
--  for instance, if I use one variable in the first half of a function, 
stop using that variable, and start using another one, the compiler can 
save me some stack space by putting them at the same address.

Plus it's a bit more straightforward to make a performant check for 
whether a type might be a pointer than for whether a stackframe might 
have a pointer. With types, it takes one pointer dereference. With 
stackframes, you have to look through some dictionary stored somewhere.


More information about the Digitalmars-d-learn mailing list