static void arrays under garbage control?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 26 10:07:03 PST 2015


On 2/26/15 11:57 AM, captaindet wrote:
> On 2015-02-26 10:07, Steven Schveighoffer wrote:
>> Static data I believe is always scanned conservatively because no
>> type information is stored for it ever, even on allocation (i.e.
>> program startup).
>
> ouh, the confusion goes on... are you saying that
>
> {
>      // will be all scanned by GC for
>      // potential pointers into GC managed memory:
>      void[16] buffer0 = void;
>      ubyte[16] buffer1;
>      uint[4] buffer3;

Yes, all 3 are stack based. This is not static data, which would be like 
uint[4] at module level. Those are also treated as scannable, as the 
entire stack of every thread is scanned.

>      // will not be scanned by GC for pointers:
>      void[] buffer4 = cast(void[])(new ubyte[16]);
>      uint[] buffer5 = cast(uint[])(new ubyte[16]);

Correct, since they are allocated as ubyte[]. uint[] also would not be 
scanned.

-Steve


More information about the Digitalmars-d-learn mailing list