[D1] gc safety

Simen kjaeraas simen.kjaras at gmail.com
Tue Oct 12 15:48:32 PDT 2010


%u <e at ee.com> wrote:

> How gc unfriendly is an union of objects and sizet_t?
>
> union{
>   size_t arr[10];
>   Class obj[10];
> }

All elements of this union will be considered pointers by the GC.


> And, if multiple arrays contain exclusively the same objects, is it then
> safe/useful to mark all but the smallest array with gc.hasNoPointers?
> Any object removal/addition happens simultaneous across all the arrays.

As long as there is at least one GC registered pointer to the allocated
objects, it will not be collected. Hence, if some arrays are permutations
or subsets of another array, only the original array need to be marked as
having pointers.

-- 
Simen


More information about the Digitalmars-d-learn mailing list