Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

MemoryOwner docs should have a warning about the maximum supported length

Đang mở
#296 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
52/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
documentation

Hướng nghiên cứu

Đọc docs/high-performance/MemoryOwner.md và xem xét lại hướng dẫn về MemoryOwner cùng với hành vi của API được liên kết. Thêm cảnh báo rằng ArrayPool.Shared chỉ hỗ trợ các mảng được pool có tối đa 2^20 phần tử, đồng thời giải thích rằng các cấp phát lớn hơn nên sử dụng Allocate với một ArrayPool có kích thước phù hợp. Hoàn thành khi giới hạn và phương án thay thế đã rõ ràng đối với người đọc.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

dotnet dotnet-communitytoolkit/prod Pri2

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:

https://github.com/dotnet/coreclr/blob/a9f3fc16483eecfc47fb79c362811d870be02249/src/System.Private.CoreLib/shared/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs#L142

                // 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.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
168
Fork
135
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MicrosoftDocs/CommunityToolkit

Tất cả issue của MicrosoftDocs/CommunityToolkit

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.