Suppose any reference type is stored in some memory location and its data is continuously expanding for example appending string in loop in StringBuilder.
How memory manager manages the scenario when its object doesnt has contiguous memory available at that location.
It would be great if any one can explain it in detail.
It just gets moved to a block of memory that is large enough to hold the expanded object. This is why you should always try to estimate how big your objects are likely to grow and reserve enough space, to minimise these operations.
Beyond Richard's answer, note that you can run into an OutOfMemoryException when no contiguous block of the desired size is available, i.e. when the memory is fragmented. Also, the desired size is in multiples of 64k.
Last Visit: 31-Dec-99 18:00 Last Update: 27-Oct-16 16:43