Code: Select all
for( int r=0; r < RowCount; r++ )
{
for( int c=0; c < ColumnCount; c++ )
{
Cell newCell = cells[ c, r ].NextGeneration();
//old line
//cells[ c, r ] = newCell;
//new line
cells[c,r].UpdateCell(newCell);
}
}
Can someone explain this comment, or why it works like that? I thought arrays held pointers to objects, and when an element is replaced, the pointer is 're-pointed'. The old object would then be GCed (or mark for GC) right away in 'old line', instead of the newCell instance in 'new line'; same net effect in my mind. Or what is the GC doing?
Sorry, relatively inexperienced in this particular part of memory optimization...and hopefully I posed the question semi-clearly
