digitalmars.D.learn - [D1] gc safety
- %u (14/14) Oct 10 2010 How gc unfriendly is an union of objects and sizet_t?
- %u (2/15) Oct 12 2010
- Simen kjaeraas (8/16) Oct 12 2010 As long as there is at least one GC registered pointer to the allocated
- %u (6/21) Oct 12 2010 The object will always occupy a continuous obj[0..x], is there some way ...
- Simen kjaeraas (6/18) Oct 12 2010 Perhaps. Is there a way to explain it to me? Do you mean the first x
- %u (2/18) Oct 13 2010 Exactly that.
- Simen kjaeraas (7/11) Oct 13 2010 No. The GC only cares about whole blocks, not singular locations within
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:The object will always occupy a continuous obj[0..x], is there some way to explain this to the GC?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.Thanks :) The GC will probably really like this as one of the arrays is cubed the size of the smallest one :DAnd, 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.
Oct 12 2010
%u <e ee.com> wrote:== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s articlePerhaps. 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%u <e ee.com> wrote:The object will always occupy a continuous obj[0..x], is there some way to explain this to the GC?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.
Oct 12 2010
== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s article%u <e ee.com> wrote:Exactly that.== Quote from Simen kjaeraas (simen.kjaras gmail.com)'s articlePerhaps. 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?%u <e ee.com> wrote:The object will always occupy a continuous obj[0..x], is there some way to explain this to the GC?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.
Oct 13 2010
%u <e ee.com> wrote: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. -- SimenPerhaps. 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?Exactly that.
Oct 13 2010