GC scan for pointers
thedeemon via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 10 02:58:41 PST 2016
On Wednesday, 9 March 2016 at 15:14:02 UTC, Gerald Jansen wrote:
> I've studied [1] and [2] but don't understand everything there.
> Hence these dumb questions:
>
> Given
>
> enum n = 100_000_000; // some big number
> auto a = new ulong[](n);
> auto b = new char[8][](n);
> struct S { ulong x; char[8] y; }
> auto c = new S[](n);
>
> 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?
I've just tested it with my GC tracker (
https://bitbucket.org/infognition/dstuff ), all 3 allocations go
with flags APPENDABLE | NO_SCAN which means these blocks will not
be scanned.
But if you define S as
struct S { ulong x; char[] y; }
so there is some pointer inside, then it gets allocated with just
APPENDABLE flag, i.e. it will be scanned then.
More information about the Digitalmars-d-learn
mailing list