Large Objects

You need to be aware of one more optimization. If an object is larger than 20,000 bytes, then it is allocated from the large object heap. The heap looks identical programmatically to the managed heap for smaller objects. An object in the large object heap ages through three generations, just like an object in the managed heap for small objects. The same rules apply for finalization of large objects as for small objects. The CLR makes one distinction in handling objects in the large object heap versus the managed heap for small objects: After objects in the large object heap are freed, the CLR does not try to compact the objects in the heap.

Two samples have been built in the LargeObject and LOC subdirectories that allocate a large ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.