.NET Framework 4.7.1 includes changes that improve background GC performance. It allows large object allocations during part of the BGC sweep phase, and the large objects allocated during this time must be marked correctly in the allocator or they will be erroneously reclaimed. A GC can be triggered during the large object allocator code path, and if the following happens, this bug will be triggered:
- This is a BGC.
- The range for BGC changed from the previous range (ie, a new segment is allocated outside of the previous range).
- The new large object is in the region that didn't exist in the previous range.
- The new large object did its marking during the BGC sweep phase.
This set of conditions make this bug very rare.
Since GC doesn't shrink the range, it means this bug usually is only seen very early on during a process or when you suddenly allocate more large objects than before, which requires acquiring a new segment that's outside the heap range.
This problem impacts applications that run with the background GC enabled and that also allocate
and free large objects at a high rate. As described in the article [Fundamentals of Garbage Collection](https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals#the-managed-heap),
The most practical workaround is to disable background GC by setting the `enabled` attribute of the [<gcConcurrent> element](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcconcurrent-element) in the