-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
We build a library that uses the ratio between GCMemoryInfo.MemoryLoadBytes/GCMemoryInfo.TotalAvailableMemoryBytes returned form the GC.GetGCMemoryInfo API to monitor memory consumption an compact a cache when consumption runs above thresholds. We now have a customer report that the cache compact is constantly triggered and it turn out it is because this ratio is seemingly always at 99% when running in .NET 8 on Mac OS 14. Running on .NET 7 on the same machine returns the actual value (corresponding to what is seen in system tools). The value is also correct on Windows and in Linux containers in .NET 8.
Reproduction Steps
Note: I don't actually have Mac to reproduce this on, so this is a bit hypothetical:
- Create an app that calls the GC.GetGCMemoryInfo API and outputs/logs the GCMemoryInfo.MemoryLoadBytes/GCMemoryInfo.TotalAvailableMemoryBytes ratio.
- Add a forced GC.Collect() call before, to make sure the values are updated.
- Run the app on MacOS 14.
Expected behavior
The output memory load ratio is roughly the same as can be seen in the OS tools.
Actual behavior
The output memory load is always basically 100% memory utilization, regardless of the actual memory pressure as can be seen in OS tools.
Note: This only happens on Mac OS X 14, on Windows and Linux (container) the output is the expected.
Regression?
Yes, in .NET 7 the returned value is correct.
Known Workarounds
No response
Configuration
.NET 8 RTM
Mac OS 14
ASP.NET Core application
Other information
No response