Skip to content
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

Workaround GC.GetMemoryInfo() ARM32 issue #2025

Merged
merged 4 commits into from
Feb 22, 2022

Conversation

antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented Feb 21, 2022

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Workaround dotnet/runtime#65466 by using the constant fallback pool size if negative memory is reported.

Fixes #2001.

@@ -74,6 +74,10 @@ public UniformUnmanagedMemoryPoolMemoryAllocator(int? maxPoolSizeMegabytes)
this.nonPoolAllocator = new UnmanagedMemoryAllocator(unmanagedBufferSizeInBytes);
}

// This delegate allows overriding the method returning the available system memory,
// so we can test our workaround for https://github.com/dotnet/runtime/issues/65466
internal static Func<long> GetTotalAvailableMemoryBytes { get; set; } = () => GC.GetGCMemoryInfo().TotalAvailableMemoryBytes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing a condition here.

#if NETCOREAPP3_1_OR_GREATER

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonfirsov I've pushed the fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the comment and also pushed it 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubled fixed now then. We know it's good 😄

@antonfirsov antonfirsov merged commit 3259c94 into main Feb 22, 2022
@antonfirsov antonfirsov deleted the af/TotalAvailableMemoryBytes-workaround branch February 22, 2022 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default MemoryAllocator creation crashes on Raspberry Pi OS 11
2 participants