Large Object Heap compaction

suggest change

By default the Large Object Heap is not compacted, unlike the small object heap, which can lead to memory fragmentation and then to OutOfMemoryExceptions.

Starting with .NET 4.5.1 there is an option to explicitly compact the Large Object Heap (along with a garbage collection):

GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect();

Treat this like any other explicit GC.Collect request and avoid it unless you have measured a large-object fragmentation problem. It can distort the GC's statistics and hurt later collections.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents