Default strategy for large object heap compaction

141 Views Asked by At

What is, by default, the strategy used by the .NET framework to compact the large object heap?

  • never compacted
  • compacted after a while (not as aggressively as generational heap)

What holds? If "after a while", are there a few details about "how long" or "when"?

(I'm interested in .NET framework versions higher than 4.5)

1

There are 1 best solutions below

2
On BEST ANSWER

By default, the LOH is not compacted at all. Because that could be expensive.

From 4.5.1 on, you can us GCSettings to change that. The choices are CompactOnce and Never.

So you can manually trigger a Compaction, driven by your application logic.

The LOH is only collected (sweeped) during a Generation 2 collection. That may cause your "after a while" confusion. But collection is not compaction.