digitalmars.D.learn - [D1] gc safety
- %u <e ee.com> Oct 10 2010
- %u <e ee.com> Oct 12 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Oct 12 2010
- %u <e ee.com> Oct 12 2010
- %u <e ee.com> Oct 13 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Oct 12 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Oct 13 2010
How gc unfriendly is an union of objects and sizet_t?
union{
size_t arr[10];
Class obj[10];
}
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.
void remove(size_t i){
size_t i2 = arr[i].i2;
arr2[i2] = null;
arr[i] = null;
}
ps. I was tempted to make the subject "[D1,gc(safety),union]"..
Oct 10 2010
Please tell me if anything is unclear/stupid :) == Quote from %u (e ee.com)'s articleHow gc unfriendly is an union of objects and sizet_t? union{ size_t arr[10]; Class obj[10]; } 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. void remove(size_t i){ size_t i2 = arr[i].i2; arr2[i2] = null; arr[i] = null; }
Oct 12 2010
%u <e 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
Oct 12 2010
== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s article%u <e ee.com> wrote:How gc unfriendly is an union of objects and sizet_t? union{ size_t arr[10]; Class obj[10]; }
this to 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.
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.
The GC will probably really like this as one of the arrays is cubed the size of the smallest one :D
Oct 12 2010
== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s article%u <e ee.com> wrote:== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s article%u <e ee.com> wrote:How gc unfriendly is an union of objects and sizet_t? union{ size_t arr[10]; Class obj[10]; }
to explain this to the GC?
elements will be objects, and the rest will be size_ts that are not pointers?
Oct 13 2010
%u <e ee.com> wrote:== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s article%u <e ee.com> wrote:How gc unfriendly is an union of objects and sizet_t? union{ size_t arr[10]; Class obj[10]; }
to explain this to the GC?
Perhaps. Is there a way to explain it to me? Do you mean the first x elements will be objects, and the rest will be size_ts that are not pointers? -- Simen
Oct 12 2010
%u <e ee.com> wrote:Perhaps. Is there a way to explain it to me? Do you mean the first x elements will be objects, and the rest will be size_ts that are not pointers?
No. The GC only cares about whole blocks, not singular locations within each. That said, there is a bug report with a GC that uses precise scanning (http://d.puremagic.com/issues/show_bug.cgi?id=3463). As you are using D1, I believe it should work for you. -- Simen
Oct 13 2010









%u <e ee.com> 