Skip to content

.Net 7 + 8 Garbage Collection Regression Issue #95191

@crollins7

Description

@crollins7

Description
I had a .Net 6 app that would experience a very slow memory leak. Due to this behavior I set the app pool to automatically recycle every 2 hours. I upgraded the app to .Net 7 with hopes that would resolve the issue and instead the memory leak exploded (14 Gb's/Hour). When I would do a memory dump and analyze I noticed that almost all of the memory is listed as "Free". I recently upgraded the app to .Net 8 and the memory leak persists.

Following @Maoni0's blog post https://maoni0.medium.com/is-the-regression-in-gc-or-something-else-38f10018dd21, I referenced clrgc.dll in the runtime config and the symptoms are significantly relieved which I believe indicates a regression in GC starting in .Net 7.

Configuration

  • .Net 8
  • Windows Server 2016 14393.6351
  • x64
  • VM with 8x Core Xeon 4309Y and 32 Gb's of Ram

Regression
As described above there was a slower memory leak originally on .Net 6 and then in .Net 7 and .Net 8 I experienced an insane regression.

Data
Additional Stats gathered when I was on .Net 7 without clrgc.dll

  • GC committed bytes increases like crazy throughout the apps runtime.
  • GC Fragmentation > 95%
  • GC Heap Size seems relatively stable around 1 GB
  • The large fragmented memory blocks are all System.Byte[]

The Link Below has Top Level GC Traces and CPU Sample Traces both taken for 1 hour with and without clrgc.dll referenced.
https://drive.google.com/file/d/1nJ8lROr4pYN4IQf4E4KoQDxBN0M5XdfA/view?usp=sharing

This highlights the performance impact experienced with and without clrgc.dll referenced in runtime settings.
image

Analysis
I have no clue the relevant code that may cause this. I am happy to do any additional testing that would be useful in helping to identify the cause.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions