-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected values reported by GC.GetGCMemoryInfo() #55126
Comments
Tagging subscribers to this area: @dotnet/gc Issue DetailsContextWorking on an attempt to improve array pooling strategies in ImageSharp. I want to use IssueI have a small test app doing some stressing work by allocating and retaing arrays of 1MB, and querying My test environment: Windows 10, 64bit physical memory, i9 with 10 physical cores A couple of unexpected things about
If /cc @Maoni0
|
I've run the repro code on my machine, with this setup:
This seems to confirm the issue on 64 bit systems. Log (click to expand):
Full log: memoryinfo.log Hope this helps! 😄 |
memory load means what's loaded in the physical memory. the test allocates ~1 mb object each time but it doesn't touch most of it so the memory load basically doesn't change. @gewarren could we please clarify this in the doc?. if you actually touch the pages of the object, eg, via the TouchPage method in this benchmark, you'll see the MemoryLoad field go up. as for TotalAvailableMemoryBytes and HighMemoryLoadThreshold values for "5.0/6.0 32 bit", are you sure this is a 32-bit app? GC just gets the total physical memory from the OS layer. |
Thanks! I updated my test app to touch the pages, and the 64bit output makes sense on my 16GB laptop now:
Yes, I print the value of Here is the (TouchPage-updated) output for While output for This looks like a regression to me. |
This was introduced by https://github.com/dotnet/runtime/pull/36152/files#diff-0edd676d0ef86c3df8cd23f712913c82d9106d1ea944d62e34189534bb817a5fL402-L410 Before this change, we treated the virtual < physical case as restricted environment and used the virtual memory limit as the limit. IIRC, I made this change since the restricted environment turns on @Maoni0 Do you think we should go back to treating the virtual < physical case as restricted environment, or should we just cap the physical memory limit by the available virtual space? |
oh interesting, I remember reviewing your PR @jkotas but I don't actually remember this particular part. maybe I missed it (if we did have a discussion about it I certainly don't remember now..). I think we should keep the previous behavior because when we get the memory load we'd want to get it based on the restricted_limit otherwise on a machine with a lot of physical mem we could be getting very low memory load but for the 32-bit process we want to get it based on the virtual. |
I agree that we should use the virtual address space as the limit. The part that I have doubts about is whether |
looking at the code before that PR,
is_restricted didn't matter for 32-bit processes anyway since hard_limit is only turned on for 64-bit processes. |
Context
Working on an attempt to improve array pooling strategies in ImageSharp. I wanted to use
GCMemoryInfo.MemoryLoadBytes
in a similar manner as done byTlsOverPerCoreLockedStacksArrayPool
Issue
I have a small test app doing some stressing work by allocating and retaing arrays of 1MB, and querying
GC.GetGCMemoryInfo
which seems to report weird values:https://gist.github.com/antonfirsov/01bb6b7b8569027cd71988ff33c66228
My test environment: Windows 10, 64bit physical memory, i9 with 10 physical cores
A couple of unexpected things about
GCMemoryInfo.MemoryLoadBytes
:MemoryLoadBytes
is gradually scaling with my actual memory usage.GCMemoryInfo.MemoryLoadBytes
reports values 10-50 times higher than the actual memory usage. These values do not make sense in a 32 bit process.GCMemoryInfo.MemoryLoadBytes
immediately jumps to a constant ~21GB value which doesn't change even ifGC.GetTotalMemory()
passes that threshold.TotalAvailableMemoryBytes
andHighMemoryLoadThreshold
are also weird:TotalAvailableMemoryBytes
. Is it only reporting the amount of physical memory on my PC without any impact on GC behavior?Note that if the
MemoryLoadBytes
issue is a bug, it must be breaking the pressure-triggered trimming ofArrayPool<T>.Shared
./cc @Maoni0
The text was updated successfully, but these errors were encountered: