Large Object Heap compaction C# with Example



Large Object Heap compaction C# with Example

By default the Large Object Heap is not compacted unlike the classic Object Heap which can lead to memory 
fragmentation and further, can lead 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(); 
Just as any explicit garbage collection request (it's called request because the CLR is not forced to conduct it) use 
with care and by default avoid it if you can since it can de-calibrate GCs statistics, decreasing its performance. 
 

Microsoft.Exchange.WebServices 

0 Comment's

Comment Form

Submit Comment