Skip to content

.NET8 GC not releasing memory back to OS #122456

@vikramrkulkarni

Description

@vikramrkulkarni

Description

I have recently migrated a .NET6 app to .NET8. During testing, we saw that calling GC is not reducing the working set. I have read #95191 and my issue looks different.

The issue with .NET8 is post calling GC.Collect(), it is not releasing as much memory back to OS as it used to do on .NET6. I have tried setting GCCollectionMode.Aggressive and it did not have any impact.

If I use clrgc.dll, then my .NET8 app behaves like .NET6.

Mine is a fairly large server side app and typically uses around 128+ GB of RAM.

Impact of this behaviour change:

  • The app is triggering false alerts with respect to memory usage
  • It is affecting our decision on how much RAM to use

Reproduction Steps

Unfortunately I dont have an easy way to repro the issue. I did build a standalone app but is behaving as expected. If I run GC with Aggressive mode, it brings down working set as expected. Please let me know how I can help you - any proc dumps, counters etc and I will supply them.

Expected behavior

When GC.Collect is called, I expect it to return back the same amount of memory to OS as it did on .NET8.

Actual behavior

After calling GC.Collect, it is only returning around 20% of the memory back to OS.

Regression?

yes, worked on .NET6 and even in .NET8, if I use clrgc.dll, it works as expected.

Known Workarounds

No response

Configuration

.NET8
Windows 11 or Windows Server 2022
x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions