[Supported in the .NET Framework 4.5.1 and later versions]
Gets or sets a value that indicates whether a full blocking garbage collection compacts the large object heap (LOH).
Assembly: mscorlib (in mscorlib.dll)
The default value of the property is GCLargeObjectHeapCompactionMode.Default, which indicates that the LOH is not compacted during garbage collections. If you assign the property a value of GCLargeObjectHeapCompactionMode.CompactOnce, the LOH is compacted during the next full blocking garbage collection, and the property value is reset to GCLargeObjectHeapCompactionMode.Default.
Background garbage collections are not blocking. This means that, if you set the property to GCLargeObjectHeapCompactionMode.CompactOnce, any background generation 2 collections that occur subsequently do not compact the LOH. Only the first blocking generation 2 collection compacts the LOH.
After the property is set to GCLargeObjectHeapCompactionMode.CompactOnce, the next full blocking garbage collection (and compaction of the LOH) occurs at an indeterminate future time. You can compact the LOH immediately by using code like the following: