Skip to content

Conversation

0xfeeddeadbeef
Copy link
Contributor

It should not be assumed that the returned array will be exactly the length requested.

For example, if you run this script using Windows PowerShell, eventually red messages will start appearing:

using assembly "C:\Users\UserName\.nuget\system.buffers\4.4.0\lib\netstandard2.0\System.Buffers.dll"

foreach ($i in 1..300000) {
  $a = [System.Buffers.ArrayPool[byte]]::Shared.Rent(16)
  if ($a.Length -ne 16) {
    Write-Host "Rented larger than minimumLength: $($a.Length)" -ForegroundColor Red
  }
}

@neuecc
Copy link
Member

neuecc commented Jul 28, 2025

Thank you, this is a correct and important point!

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.

2 participants