MemoryOwner docs should have a warning about the maximum supported length
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 52/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- documentation
Research direction
Read docs/high-performance/MemoryOwner.md and review the MemoryOwner guidance alongside the linked API behavior. Add a warning that ArrayPool.Shared supports pooled arrays only up to 2^20 elements, and explain that larger allocations should use Allocate with an appropriately sized ArrayPool. Done means the limitation and alternative are clear to readers.
Written by the indexing model from the issue text.
Description
Hi,
I'm new to the CommunityToolkit and was looking how the MemoryOwner<T> can help me to improve my code. A normal use case for me is working with monochrome camera image and therefore I need often large byte arrays. If I get the implementation right, the MemoryOwner<T> uses an ArrayPool<T> which is created from the ArrayPool<T>.Shared - but this supports only an array length up to 2^20 (1024 * 1024 = 1048576). If a larger array is reqested, it returns only a normal array:
// The request was for a size too large for the pool. Allocate an array of exactly the requested length.
// When it's returned to the pool, we'll simply throw it away.
buffer = GC.AllocateUninitializedArray<T>(minimumLength);
With that, most of the optimizations are gone!
Therefore, I think it is important to also clearly emphasize this point in the documentation. In this case the developer should use the Allocate method which accepts a ArrayPool<T> as an input parameter. This pool could be created with the right size.
Best regard,
Mike
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 1270690a-737c-ebd1-dcc9-933f7e20290e
- Version Independent ID: 1270690a-737c-ebd1-dcc9-933f7e20290e
- Content: MemoryOwner<T> - .NET Community Toolkit
- Content Source: docs/high-performance/MemoryOwner.md
- Product: dotnet-communitytoolkit
- GitHub Login: @Sergio0694
- Microsoft Alias: joverslu
- Dominant language
- No language data
- Stars
- 168
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MicrosoftDocs/CommunityToolkit
-
dotnet-communitytoolkit/svc dotnet-maui-community-toolkit/subsvc Pri2
Difficulty 1/5 1-3 hours Newbie friendliness 91/100
MicrosoftDocs/CommunityToolkit#651 · 1 comment ·
-
Just a typo?Opencommunity-toolkit/prod dotnet Pri2
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
dotnet-communitytoolkit/prod maui Pri1
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
dotnet dotnet-communitytoolkit/prod Pri1
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
MicrosoftDocs/CommunityToolkit#659 · 1 comment ·
All issues in MicrosoftDocs/CommunityToolkit
Similar issues
-
accepting PR Content:HTML
Difficulty 1/5 Under an hour Newbie friendliness 88/100
mdn/content#45988 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
pyca/verified-garbage#1023 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
quickemu-project/quickemu#1960 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100