I have a large T[]
in generation 2 on the Large Object Heap. T
is a reference type. I make the following assignment:
T[0] = new T(..);
- Which object(s) are marked as dirty for the next Gen0/Gen1 mark phases of GC? The entire array instance, or just the new instance of
T
? Will the next Gen0/Gen1 GC mark phase have to go through every item of the array? (That would seem unnecessary and very inefficient.) - Are arrays special in this regard? Would it change the answer if the collection were e.g. a
SortedList<K, T>
and I added a new, maximal item?
I've read through many questions and articles, including the ones below, but I still don't think I've found a clear answer. I'm aware that an entire range of memory is marked as dirty, not individual objects, but is the new array entry or the array itself the basis of this?