How the GC distinguishes code from data

Pelle pelle.mansson at gmail.com
Thu Jan 6 02:56:16 PST 2011


On 01/06/2011 07:31 AM, %u wrote:
>> If you have allocated a large uint[], most likely =C3=ACt will be flagged
> NO_SCAN, meaning it has no pointers in it, and the GC will ignore it.
>
>
> Ah, but the trouble is, no one said that this array has to be in the GC heap! I
> could easily have a void[] and a uint[] that both point to non-GC managed memory.
> Or I might even have a uint[] allocated on the stack! How does the GC distinguish
> these, when there's no "attribute" it can mark? (Or does it?!)

It assumes everything on the stack is pointers, at the moment, I believe.

If it's not on the garbage collected heap, it won't scan it unless you 
tell it to.


More information about the Digitalmars-d-learn mailing list