5 types derived from ArrayPool
Microsoft.AspNetCore.Components.Tests (1)
Rendering\TestArrayPool.cs (1)
8internal class TestArrayPool<T> : ArrayPool<T>
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
Buffers\PagedBufferedTextWriterTest.cs (2)
323private class TestArrayPool : ArrayPool<char> 338private class RentMoreArrayPool : ArrayPool<char>
System.Private.CoreLib (2)
src\libraries\System.Private.CoreLib\src\System\Buffers\ConfigurableArrayPool.cs (1)
9internal sealed partial class ConfigurableArrayPool<T> : ArrayPool<T>
src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs (1)
22internal sealed partial class SharedArrayPool<T> : ArrayPool<T>
1802 references to ArrayPool
Aspire.Dashboard (2)
src\Shared\CompareHelpers.cs (2)
25(requestPooled = ArrayPool<byte>.Shared.Rent(requestByteCount))).Slice(0, requestByteCount); 38ArrayPool<byte>.Shared.Return(requestPooled);
Aspire.Hosting (2)
src\Shared\CompareHelpers.cs (2)
25(requestPooled = ArrayPool<byte>.Shared.Rent(requestByteCount))).Slice(0, requestByteCount); 38ArrayPool<byte>.Shared.Return(requestPooled);
BasicWebSite (1)
Controllers\ContentNegotiation\NormalController.cs (1)
26public NormalController(ArrayPool<char> charPool)
FormatterWebSite (1)
Controllers\JsonFormatterController.cs (1)
25public JsonFormatterController(ArrayPool<char> charPool)
GenerateDocumentationAndConfigFiles (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
illink (4)
Metrics (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Metrics.Legacy (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.AspNetCore.Components (11)
NavigationManager.cs (2)
405var locationChangingHandlersCopy = ArrayPool<Func<LocationChangingContext, ValueTask>>.Shared.Rent(handlerCount); 451ArrayPool<Func<LocationChangingContext, ValueTask>>.Shared.Return(locationChangingHandlersCopy);
PersistentStateValueProvider.cs (4)
192ArrayPool<byte>.Shared.Return(pool, clearArray: true); 214var newPool = pool == null ? ArrayPool<byte>.Shared.Rent(size ?? 2048) : ArrayPool<byte>.Shared.Rent(pool.Length * 2); 219ArrayPool<byte>.Shared.Return(pool, clearArray: true);
Routing\RouteContext.cs (2)
61_pooled = ArrayPool<byte>.Shared.Rent(length); 71ArrayPool<byte>.Shared.Return(_pooled);
src\Components\Shared\src\ArrayBuilder.cs (3)
38private readonly ArrayPool<T> _arrayPool; 45public ArrayBuilder(int minCapacity = 32, ArrayPool<T> arrayPool = null) 47_arrayPool = arrayPool ?? ArrayPool<T>.Shared;
Microsoft.AspNetCore.Components.Endpoints (18)
Builder\ResourceCollectionUrlEndpoint.cs (2)
144ArrayPool<byte>.Shared.Return(rented); 146rented = ArrayPool<byte>.Shared.Rent(length);
FormMapping\Converters\CollectionAdapters\ArrayPoolBufferAdapter.cs (4)
12public static PooledBuffer CreateBuffer() => new() { Data = ArrayPool<TElement>.Shared.Rent(16), Count = 0 }; 18var newBuffer = ArrayPool<TElement>.Shared.Rent(buffer.Data.Length * 2); 20ArrayPool<TElement>.Shared.Return(buffer.Data); 31ArrayPool<TElement>.Shared.Return(buffer.Data);
FormMapping\HttpContextFormValueMapper.cs (2)
130buffer = ArrayPool<char>.Shared.Rent(options.MaxKeyBufferSize); 152ArrayPool<char>.Shared.Return(buffer);
FormMapping\PrefixResolver.cs (2)
17_sortedKeys = ArrayPool<FormKey>.Shared.Rent(count); 41ArrayPool<FormKey>.Shared.Return(_sortedKeys);
RazorComponentEndpointInvoker.cs (2)
100await using var writer = new HttpResponseStreamWriter(context.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Rendering\EndpointHtmlRenderer.EventDispatch.cs (4)
94await using var writer = new HttpResponseStreamWriter(_httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 131await using var writer = new HttpResponseStreamWriter(_httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Results\RazorComponentResultExecutor.cs (2)
65await using var writer = new HttpResponseStreamWriter(httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Microsoft.AspNetCore.Components.Endpoints.Tests (2)
Binding\FormDataMapperTests.cs (2)
2371var result = ArrayPool<int>.Shared.Rent(size); 2379ArrayPool<int>.Shared.Return(array);
Microsoft.AspNetCore.Components.Forms (2)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
13private static readonly ArrayPool<char> s_arrayPool = ArrayPool<char>.Shared;
Microsoft.AspNetCore.Components.Server (30)
BlazorPack\SequenceOfT.cs (7)
29private readonly ArrayPool<T> arrayPool; 37/// that uses a private <see cref="ArrayPool{T}"/> for recycling arrays. 40: this(ArrayPool<T>.Create()) 58public Sequence(ArrayPool<T> arrayPool) 302/// Gets the backing array, when using an <see cref="ArrayPool{T}"/> instead of a <see cref="MemoryPool{T}"/>. 371/// <param name="array">An array drawn from an <see cref="ArrayPool{T}"/>.</param> 381internal void ResetMemory(ArrayPool<T> arrayPool)
Circuits\ServerComponentDeserializer.cs (2)
309: (seenComponentIdsStorage = ArrayPool<int>.Shared.Rent(operations.Length)).AsSpan(0, operations.Length); 363ArrayPool<int>.Shared.Return(seenComponentIdsStorage);
ComponentHub.cs (2)
495var buffer = ArrayPool<byte>.Shared.Rent(32 * 1024); 507ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
src\Components\Shared\src\ArrayBuilder.cs (3)
38private readonly ArrayPool<T> _arrayPool; 45public ArrayBuilder(int minCapacity = 32, ArrayPool<T> arrayPool = null) 47_arrayPool = arrayPool ?? ArrayPool<T>.Shared;
src\Shared\PooledArrayBufferWriter.cs (5)
19_rentedBuffer = ArrayPool<T>.Shared.Rent(MinimumBufferSize); 27_rentedBuffer = ArrayPool<T>.Shared.Rent(initialCapacity); 95ArrayPool<T>.Shared.Return(_rentedBuffer); 163_rentedBuffer = ArrayPool<T>.Shared.Rent(newSize); 171ArrayPool<T>.Shared.Return(oldBuffer);
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\MessagePackReader.cs (2)
1102char[] charArray = ArrayPool<char>.Shared.Rent(maxCharLength); 1128ArrayPool<char>.Shared.Return(charArray);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\MessagePackWriter.cs (2)
1302var buffer = ArrayPool<byte>.Shared.Rent((int)sourceBytesToCopy); 1313ArrayPool<byte>.Shared.Return(buffer);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequencePool.cs (4)
45private readonly ArrayPool<byte> arrayPool; 55: this(Environment.ProcessorCount * 2, ArrayPool<byte>.Create(80 * 1024, 100)) 67: this(maxSize, ArrayPool<byte>.Create(80 * 1024, 100)) 76public SequencePool(int maxSize, ArrayPool<byte> arrayPool)
Microsoft.AspNetCore.Components.Web (2)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
13private static readonly ArrayPool<char> s_arrayPool = ArrayPool<char>.Shared;
Microsoft.AspNetCore.Components.WebAssembly (2)
src\Components\Shared\src\TransmitDataStreamToJS.cs (2)
17var buffer = ArrayPool<byte>.Shared.Rent(32 * 1024); 46ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
Microsoft.AspNetCore.Components.WebView (5)
src\Components\Shared\src\ArrayBuilder.cs (3)
38private readonly ArrayPool<T> _arrayPool; 45public ArrayBuilder(int minCapacity = 32, ArrayPool<T> arrayPool = null) 47_arrayPool = arrayPool ?? ArrayPool<T>.Shared;
src\Components\Shared\src\TransmitDataStreamToJS.cs (2)
17var buffer = ArrayPool<byte>.Shared.Rent(32 * 1024); 46ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
Microsoft.AspNetCore.DataProtection (2)
KeyManagement\KeyRingBasedDataProtector.cs (2)
372Span<int> purposeLengthsPool = targetLength <= 32 ? stackalloc int[targetLength] : (lease = ArrayPool<int>.Shared.Rent(targetLength)).AsSpan(0, targetLength); 408ArrayPool<int>.Shared.Return(lease);
Microsoft.AspNetCore.Diagnostics.Middleware (1)
Logging\HttpLoggingRedactionInterceptor.cs (1)
108var routeParams = ArrayPool<HttpRouteParameter>.Shared.Rent(routeSegments.ParameterCount);
Microsoft.AspNetCore.Http (4)
Extensions\HttpRequestRewindExtensions.cs (2)
33/// The maximum size in bytes of the in-memory <see cref="System.Buffers.ArrayPool{Byte}"/> used to buffer the 72/// The maximum size in bytes of the in-memory <see cref="System.Buffers.ArrayPool{Byte}"/> used to buffer the
src\Http\Shared\StreamCopyOperationInternal.cs (2)
36var buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 79ArrayPool<byte>.Shared.Return(buffer);
Microsoft.AspNetCore.Http.Abstractions (3)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
63ArrayPool<T>.Shared.Return(toReturn); 91T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 98ArrayPool<T>.Shared.Return(toReturn);
Microsoft.AspNetCore.Http.Connections (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.Http.Extensions (20)
RequestDelegateFactory.cs (5)
126private static readonly MethodInfo ArrayPoolSharedReturnMethod = typeof(ArrayPool<char>).GetMethod(nameof(ArrayPool<char>.Shared.Return))!; 2169Expression.Property(null, typeof(ArrayPool<char>).GetProperty(nameof(ArrayPool<char>.Shared))!), 2236buffer = ArrayPool<char>.Shared.Rent(maxKeyBufferSize);
src\Components\Endpoints\src\FormMapping\Converters\CollectionAdapters\ArrayPoolBufferAdapter.cs (4)
12public static PooledBuffer CreateBuffer() => new() { Data = ArrayPool<TElement>.Shared.Rent(16), Count = 0 }; 18var newBuffer = ArrayPool<TElement>.Shared.Rent(buffer.Data.Length * 2); 20ArrayPool<TElement>.Shared.Return(buffer.Data); 31ArrayPool<TElement>.Shared.Return(buffer.Data);
src\Components\Endpoints\src\FormMapping\PrefixResolver.cs (2)
17_sortedKeys = ArrayPool<FormKey>.Shared.Rent(count); 41ArrayPool<FormKey>.Shared.Return(_sortedKeys);
src\Http\Shared\StreamCopyOperationInternal.cs (2)
36var buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 79ArrayPool<byte>.Shared.Return(buffer);
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
63ArrayPool<T>.Shared.Return(toReturn); 91T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 98ArrayPool<T>.Shared.Return(toReturn);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (4)
27_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2)); 301ArrayPool<char>.Shared.Return(toReturn); 312ArrayPool<char>.Shared.Return(toReturn);
Microsoft.AspNetCore.Http.Results (2)
src\Http\Shared\StreamCopyOperationInternal.cs (2)
36var buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 79ArrayPool<byte>.Shared.Return(buffer);
Microsoft.AspNetCore.HttpLogging (9)
BufferingStream.cs (1)
169newSegment.SetOwnedMemory(ArrayPool<byte>.Shared.Rent(GetSegmentSize(sizeHint)));
src\Shared\Buffers\BufferSegment.cs (1)
73ArrayPool<byte>.Shared.Return(poolArray);
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
63ArrayPool<T>.Shared.Return(toReturn); 91T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 98ArrayPool<T>.Shared.Return(toReturn);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (4)
27_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2)); 301ArrayPool<char>.Shared.Return(toReturn); 312ArrayPool<char>.Shared.Return(toReturn);
Microsoft.AspNetCore.Identity (5)
Passkeys\BufferSourceJsonConverter.cs (5)
49(pooledArray = ArrayPool<byte>.Shared.Rent(utf8Unescaped.Length)); 58ArrayPool<byte>.Shared.Return(pooledArray); 69ArrayPool<byte>.Shared.Return(pooledArray); 82(pooledArray = ArrayPool<byte>.Shared.Rent(encodedLength)); 93ArrayPool<byte>.Shared.Return(pooledArray);
Microsoft.AspNetCore.Mvc.Core (15)
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (2)
232services.TryAddSingleton(ArrayPool<byte>.Shared); 233services.TryAddSingleton(ArrayPool<char>.Shared);
Infrastructure\MemoryPoolHttpRequestStreamReaderFactory.cs (6)
22private readonly ArrayPool<byte> _bytePool; 23private readonly ArrayPool<char> _charPool; 29/// The <see cref="ArrayPool{Byte}"/> for creating <see cref="T:byte[]"/> buffers. 32/// The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers. 35ArrayPool<byte> bytePool, 36ArrayPool<char> charPool)
Infrastructure\MemoryPoolHttpResponseStreamWriterFactory.cs (7)
25/// <see cref="MemoryPoolHttpResponseStreamWriterFactory"/> maintains <see cref="ArrayPool{T}"/>s 30private readonly ArrayPool<byte> _bytePool; 31private readonly ArrayPool<char> _charPool; 37/// The <see cref="ArrayPool{Byte}"/> for creating <see cref="byte"/> buffers. 40/// The <see cref="ArrayPool{Char}"/> for creating <see cref="char"/> buffers. 43ArrayPool<byte> bytePool, 44ArrayPool<char> charPool)
Microsoft.AspNetCore.Mvc.Core.Test (4)
ContentResultTest.cs (2)
261var charArrayPool = new Mock<ArrayPool<char>>(); 269new MemoryPoolHttpResponseStreamWriterFactory(ArrayPool<byte>.Shared, charArrayPool.Object)));
ModelBinding\Binders\BodyModelBinderTests.cs (2)
772: base(GetLogger(), new JsonSerializerSettings(), ArrayPool<char>.Shared, new DefaultObjectPoolProvider(), new MvcOptions(), new MvcNewtonsoftJsonOptions() 842: base(GetLogger(), new JsonSerializerSettings(), ArrayPool<char>.Shared, new DefaultObjectPoolProvider(), new MvcOptions(), new MvcNewtonsoftJsonOptions()
Microsoft.AspNetCore.Mvc.IntegrationTests (2)
TestMvcOptions.cs (2)
39var charPool = ArrayPool<char>.Shared;
Microsoft.AspNetCore.Mvc.NewtonsoftJson (16)
DependencyInjection\NewtonsoftJsonMvcOptionsSetup.cs (2)
24private readonly ArrayPool<char> _charPool; 30ArrayPool<char> charPool,
JsonArrayPool.cs (2)
11private readonly ArrayPool<T> _inner; 13public JsonArrayPool(ArrayPool<T> inner)
NewtonsoftJsonHelper.cs (2)
27/// The <see cref="ArrayPool{Char}"/> for use with custom <see cref="JsonSerializerSettings"/> (see 30public NewtonsoftJsonHelper(IOptions<MvcNewtonsoftJsonOptions> options, ArrayPool<char> charPool)
NewtonsoftJsonInputFormatter.cs (2)
39/// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> 46ArrayPool<char> charPool,
NewtonsoftJsonOutputFormatter.cs (4)
34/// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> 39ArrayPool<char> charPool, 52/// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> 57ArrayPool<char> charPool,
NewtonsoftJsonPatchInputFormatter.cs (2)
28/// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> 35ArrayPool<char> charPool,
NewtonsoftJsonResultExecutor.cs (2)
41/// <param name="charPool">The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers.</param> 47ArrayPool<char> charPool)
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (26)
JsonResultTest.cs (1)
49ArrayPool<char>.Shared);
NewtonsoftJsonHelperTest.cs (2)
26ArrayPool<char>.Shared); 93ArrayPool<char>.Shared);
NewtonsoftJsonInputFormatterTest.cs (12)
32ArrayPool<char>.Shared, 68ArrayPool<char>.Shared, 104ArrayPool<char>.Shared, 317ArrayPool<char>.Shared, 352ArrayPool<char>.Shared, 383ArrayPool<char>.Shared, 414ArrayPool<char>.Shared, 443ArrayPool<char>.Shared, 491ArrayPool<char>.Shared, 539ArrayPool<char>.Shared, 566: base(GetLogger(), settings, ArrayPool<char>.Shared, objectPoolProvider, new MvcOptions(), new MvcNewtonsoftJsonOptions()) 588ArrayPool<char>.Shared,
NewtonsoftJsonOutputFormatterTest.cs (7)
22return new NewtonsoftJsonOutputFormatter(new JsonSerializerSettings(), ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions()); 76var jsonFormatter = new NewtonsoftJsonOutputFormatter(settings, ArrayPool<char>.Shared, new MvcOptions()); 106var jsonFormatter = new NewtonsoftJsonOutputFormatter(settings, ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions() 133var jsonFormatter = new NewtonsoftJsonOutputFormatter(settings, ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions()); 351var formatter = new NewtonsoftJsonOutputFormatter(new JsonSerializerSettings(), ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions()); 382var formatter = new NewtonsoftJsonOutputFormatter(new JsonSerializerSettings(), ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions()); 555: base(serializerSettings, ArrayPool<char>.Shared, new MvcOptions(), new MvcNewtonsoftJsonOptions())
NewtonsoftJsonPatchInputFormatterTest.cs (3)
30ArrayPool<char>.Shared, 67ArrayPool<char>.Shared, 232ArrayPool<char>.Shared,
NewtonsoftJsonResultExecutorTest.cs (1)
23ArrayPool<char>.Shared);
Microsoft.AspNetCore.Mvc.ViewFeatures (15)
Buffers\ArrayPoolBufferSource.cs (2)
10private readonly ArrayPool<char> _pool; 12public ArrayPoolBufferSource(ArrayPool<char> pool)
Buffers\MemoryPoolViewBufferScope.cs (6)
14private readonly ArrayPool<ViewBufferValue> _viewBufferPool; 15private readonly ArrayPool<char> _charPool; 24/// The <see cref="ArrayPool{ViewBufferValue}"/> for creating <see cref="ViewBufferValue"/> instances. 27/// The <see cref="ArrayPool{Char}"/> for creating <see cref="PagedBufferedTextWriter"/> instances. 29public MemoryPoolViewBufferScope(ArrayPool<ViewBufferValue> viewBufferPool, ArrayPool<char> charPool)
Buffers\PagedBufferedTextWriter.cs (1)
16public PagedBufferedTextWriter(ArrayPool<char> pool, TextWriter inner)
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensions.cs (1)
208services.TryAddSingleton(ArrayPool<ViewBufferValue>.Shared);
src\Shared\PooledArrayBufferWriter.cs (5)
19_rentedBuffer = ArrayPool<T>.Shared.Rent(MinimumBufferSize); 27_rentedBuffer = ArrayPool<T>.Shared.Rent(initialCapacity); 95ArrayPool<T>.Shared.Return(_rentedBuffer); 163_rentedBuffer = ArrayPool<T>.Shared.Rent(newSize); 171ArrayPool<T>.Shared.Return(oldBuffer);
Microsoft.AspNetCore.Mvc.Views.TestCommon (1)
TestViewBufferScope.cs (1)
28return new PagedBufferedTextWriter(ArrayPool<char>.Shared, writer);
Microsoft.AspNetCore.OpenApi (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.OutputCaching (8)
OutputCacheEntry.cs (2)
90var arr = ArrayPool<(string, StringValues)>.Shared.Rent(count); 100ArrayPool<(string, StringValues)>.Shared.Return(arr);
OutputCacheEntryFormatter.cs (3)
52ArrayPool<string>.Shared.Return(lease); 80lease = ArrayPool<string>.Shared.Rent(tags.Count); 267var headerArr = ArrayPool<(string Name, StringValues Values)>.Shared.Rent(headersCount);
RecyclableArrayBufferWriter.cs (3)
39ArrayPool<T>.Shared.Return(tmp); 119_buffer = ArrayPool<T>.Shared.Rent(newSize); 123ArrayPool<T>.Shared.Return(oldArray);
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (6)
EndToEndBenchmarks.cs (6)
41ArrayPool<byte>.Shared.Return(arr); 52_payloadOversized = ArrayPool<byte>.Shared.Rent(PayloadLength); 207var oversized = ArrayPool<byte>.Shared.Rent(PayloadLength); 214ArrayPool<byte>.Shared.Return(oversized); 273ArrayPool<byte>.Shared.Return(arr); 277public NullPipeWriter(int size) => _buffer = ArrayPool<byte>.Shared.Rent(size);
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (2)
RedisOutputCacheStore.cs (2)
257leased = ArrayPool<byte>.Shared.Rent(len); 266ArrayPool<byte>.Shared.Return(leased);
Microsoft.AspNetCore.OutputCaching.Tests (3)
OutputCacheEntryFormatterTests.cs (3)
183ArrayPool<byte>.Shared.Return(xBuffer); 187ArrayPool<byte>.Shared.Return(yBuffer); 199lease = ArrayPool<byte>.Shared.Rent(len);
Microsoft.AspNetCore.Owin (2)
WebSockets\OwinWebSocketAdapter.cs (2)
138var buffer = ArrayPool<byte>.Shared.Rent(_rentedBufferSize); 149ArrayPool<byte>.Shared.Return(buffer);
Microsoft.AspNetCore.Server.Kestrel.Core (20)
Internal\Http\Http1OutputProducer.cs (3)
427ArrayPool<byte>.Shared.Return(_fakeMemory); 690ArrayPool<byte>.Shared.Return(_fakeMemory); 709return _fakeMemory = ArrayPool<byte>.Shared.Rent(minSize);
Internal\Http\HttpParser.cs (2)
428Span<byte> headerSpan = headerLength <= 256 ? stackalloc byte[256] : array = ArrayPool<byte>.Shared.Rent(headerLength); 455ArrayPool<byte>.Shared.Return(array);
Internal\Http2\Http2FrameWriter.cs (5)
659largeHeaderBuffer = ArrayPool<byte>.Shared.Rent(_headersEncodingLargeBufferSize); 670ArrayPool<byte>.Shared.Return(largeHeaderBuffer); 688ArrayPool<byte>.Shared.Return(largeHeaderBuffer); 691largeHeaderBuffer = ArrayPool<byte>.Shared.Rent(_headersEncodingLargeBufferSize); 702ArrayPool<byte>.Shared.Return(largeHeaderBuffer);
Internal\Http2\Http2OutputProducer.cs (3)
240ArrayPool<byte>.Shared.Return(_fakeMemory); 680ArrayPool<byte>.Shared.Return(_fakeMemory); 699return _fakeMemory = ArrayPool<byte>.Shared.Rent(minSize);
Internal\Http3\Http3OutputProducer.cs (3)
86ArrayPool<byte>.Shared.Return(_fakeMemory); 247ArrayPool<byte>.Shared.Return(_fakeMemory); 266return _fakeMemory = ArrayPool<byte>.Shared.Rent(minSize);
Internal\Infrastructure\PipeWriterHelpers\ConcurrentPipeWriter.cs (1)
367newSegment.SetOwnedMemory(ArrayPool<byte>.Shared.Rent(minSize));
src\Shared\Buffers\BufferSegment.cs (1)
73ArrayPool<byte>.Shared.Return(poolArray);
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (2)
128private static ArrayPool<byte> Pool => ArrayPool<byte>.Shared;
Microsoft.AspNetCore.Shared.Tests (2)
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (2)
128private static ArrayPool<byte> Pool => ArrayPool<byte>.Shared;
Microsoft.AspNetCore.SignalR.Client.Tests (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.SignalR.Common (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.SignalR.Common.Tests (2)
Internal\Protocol\MemoryBufferWriterTests.cs (2)
20var buffer = ArrayPool<byte>.Shared.Rent(1); 23ArrayPool<byte>.Shared.Return(buffer);
Microsoft.AspNetCore.SignalR.Core (2)
Internal\Utf8HashLookup.cs (2)
84(pooled = ArrayPool<char>.Shared.Rent(count)); 89ArrayPool<char>.Shared.Return(pooled);
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (6)
src\SignalR\common\Shared\JsonUtils.cs (3)
198private readonly ArrayPool<T> _inner; 200internal static readonly JsonArrayPool<T> Shared = new JsonArrayPool<T>(ArrayPool<T>.Shared); 202public JsonArrayPool(ArrayPool<T> inner)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.SignalR.Specification.Tests (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.SignalR.StackExchangeRedis (3)
src\SignalR\common\Shared\MemoryBufferWriter.cs (3)
95ArrayPool<byte>.Shared.Return(_currentSegment); 187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint)); 401ArrayPool<byte>.Shared.Return(Buffer);
Microsoft.AspNetCore.WebSockets (7)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
63ArrayPool<T>.Shared.Return(toReturn); 91T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 98ArrayPool<T>.Shared.Return(toReturn);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (4)
27_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2)); 301ArrayPool<char>.Shared.Return(toReturn); 312ArrayPool<char>.Shared.Return(toReturn);
Microsoft.AspNetCore.WebUtilities (45)
BufferedReadStream.cs (3)
20private readonly ArrayPool<byte> _bytePool; 31: this(inner, bufferSize, ArrayPool<byte>.Shared) 41public BufferedReadStream(Stream inner, int bufferSize, ArrayPool<byte> bytePool)
FileBufferingReadStream.cs (7)
21private readonly ArrayPool<byte> _bytePool; 57: this(inner, memoryThreshold, bufferLimit, tempFileDirectoryAccessor, ArrayPool<byte>.Shared) 68/// <param name="bytePool">The <see cref="ArrayPool{T}"/> to use.</param> 74ArrayPool<byte> bytePool) 109: this(inner, memoryThreshold, bufferLimit, tempFileDirectory, ArrayPool<byte>.Shared) 120/// <param name="bytePool">The <see cref="ArrayPool{T}"/> to use.</param> 126ArrayPool<byte> bytePool)
FileBufferingWriteStream.cs (1)
55PagedByteBuffer = new PagedByteBuffer(ArrayPool<byte>.Shared);
FormPipeReader.cs (2)
360var byteArray = ArrayPool<byte>.Shared.Rent((int)ros.Length); 370ArrayPool<byte>.Shared.Return(byteArray);
FormReader.cs (8)
37private readonly ArrayPool<char> _charPool; 51: this(data, ArrayPool<char>.Shared) 59/// <param name="charPool">The <see cref="ArrayPool{T}"/> to use.</param> 60public FormReader(string data, ArrayPool<char> charPool) 74: this(stream, Encoding.UTF8, ArrayPool<char>.Shared) 84: this(stream, encoding, ArrayPool<char>.Shared) 93/// <param name="charPool">The <see cref="ArrayPool{T}"/> to use.</param> 94public FormReader(Stream stream, Encoding encoding, ArrayPool<char> charPool)
HttpRequestStreamReader.cs (8)
22private readonly ArrayPool<byte> _bytePool; 23private readonly ArrayPool<char> _charPool; 42: this(stream, encoding, DefaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared) 53: this(stream, encoding, bufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared) 69ArrayPool<byte> bytePool, 70ArrayPool<char> charPool)
HttpResponseStreamWriter.cs (8)
22private readonly ArrayPool<byte> _bytePool; 23private readonly ArrayPool<char> _charPool; 38: this(stream, encoding, DefaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared) 49: this(stream, encoding, bufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared) 65ArrayPool<byte> bytePool, 66ArrayPool<char> charPool)
MultipartReaderStream.cs (3)
13private readonly ArrayPool<byte> _bytePool; 26: this(stream, boundary, ArrayPool<byte>.Shared) 36public MultipartReaderStream(BufferedReadStream stream, MultipartBoundary boundary, ArrayPool<byte> bytePool)
PagedByteBuffer.cs (2)
12private readonly ArrayPool<byte> _arrayPool; 16public PagedByteBuffer(ArrayPool<byte> arrayPool)
StreamHelperExtensions.cs (3)
26return stream.DrainAsync(ArrayPool<byte>.Shared, null, cancellationToken); 41return stream.DrainAsync(ArrayPool<byte>.Shared, limit, cancellationToken); 55public static async Task DrainAsync(this Stream stream, ArrayPool<byte> bytePool, long? limit, CancellationToken cancellationToken)
Microsoft.AspNetCore.WebUtilities.Tests (51)
FileBufferingReadStreamTests.cs (6)
408var arrayPool = new Mock<ArrayPool<byte>>(); 410.Returns((int m) => ArrayPool<byte>.Shared.Rent(m)); 412.Callback((byte[] bytes, bool clear) => ArrayPool<byte>.Shared.Return(bytes, clear)); 437var arrayPool = new Mock<ArrayPool<byte>>(); 439.Returns((int m) => ArrayPool<byte>.Shared.Rent(m)); 441.Callback((byte[] bytes, bool clear) => ArrayPool<byte>.Shared.Return(bytes, clear));
HttpRequestStreamReaderTest.cs (16)
344public static void NullInputsInConstructor_ExpectArgumentNullException(Stream stream, Encoding encoding, ArrayPool<byte> bytePool, ArrayPool<char> charPool) 359var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, size, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 370var httpRequestStreamReader = new HttpRequestStreamReader(mockStream.Object, Encoding.UTF8, 1, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 378var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 391var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 441yield return new object?[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 442yield return new object?[] { new MemoryStream(), null, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 443yield return new object?[] { new MemoryStream(), Encoding.UTF8, null, ArrayPool<char>.Shared }; 444yield return new object?[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
HttpResponseStreamWriterTest.cs (18)
695ArrayPool<byte>.Shared, 696ArrayPool<char>.Shared)) 732public static void NullInputsInConstructor_ExpectArgumentNullException(Stream stream, Encoding encoding, ArrayPool<byte> bytePool, ArrayPool<char> charPool) 747var httpRequestStreamReader = new HttpRequestStreamReader(new MemoryStream(), Encoding.UTF8, size, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 758var httpRequestStreamReader = new HttpRequestStreamReader(mockStream.Object, Encoding.UTF8, 1, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 766var httpResponseStreamWriter = new HttpResponseStreamWriter(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 779var httpResponseStreamWriter = new HttpResponseStreamWriter(new MemoryStream(), Encoding.UTF8, 10, ArrayPool<byte>.Shared, ArrayPool<char>.Shared); 848yield return new object?[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 849yield return new object?[] { new MemoryStream(), null, ArrayPool<byte>.Shared, ArrayPool<char>.Shared }; 850yield return new object?[] { new MemoryStream(), Encoding.UTF8, null, ArrayPool<char>.Shared }; 851yield return new object?[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
PagedByteBufferTest.cs (11)
17using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 34using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 51using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 68using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 85using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 101using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 126using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 150using var buffer = new PagedByteBuffer(ArrayPool<byte>.Shared); 171var arrayPool = new Mock<ArrayPool<byte>>(); 197var arrayPool = new Mock<ArrayPool<byte>>(); 222var arrayPool = new Mock<ArrayPool<byte>>();
Microsoft.CodeAnalysis (4)
Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
Microsoft.CodeAnalysis.Analyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.AnalyzerUtilities (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.BannedApiAnalyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.CodeStyle (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.PublicApiAnalyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.ResxSourceGenerator (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.CodeAnalysis.Workspaces (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.Extensions.AI (6)
ChatCompletion\ChatResponse{T}.cs (2)
100var buffer = ArrayPool<byte>.Shared.Rent(utf8ByteLength); 110ArrayPool<byte>.Shared.Return(buffer);
ChatCompletion\DistributedCachingChatClient.cs (2)
147object?[] arr = ArrayPool<object?>.Shared.Rent(length); 161ArrayPool<object?>.Shared.Return(arr);
Embeddings\DistributedCachingEmbeddingGenerator.cs (2)
118object?[] arr = ArrayPool<object?>.Shared.Rent(length); 130ArrayPool<object?>.Shared.Return(arr);
Microsoft.Extensions.AI.Abstractions (10)
Contents\DataContent.cs (2)
155char[] array = ArrayPool<char>.Shared.Rent( 163ArrayPool<char>.Shared.Return(array);
Embeddings\BinaryEmbedding.cs (4)
65tmpArray = ArrayPool<byte>.Shared.Rent(length); 83ArrayPool<byte>.Shared.Return(tmpArray); 98byte[] tmpArray = ArrayPool<byte>.Shared.Rent(length); 108ArrayPool<byte>.Shared.Return(tmpArray);
Functions\AIFunctionFactory.cs (4)
1122_buffer = ArrayPool<byte>.Shared.Rent(initialCapacity); 1186ArrayPool<byte>.Shared.Return(_buffer); 1201byte[] newBuffer = ArrayPool<byte>.Shared.Rent(newCapacity); 1204ArrayPool<byte>.Shared.Return(_buffer);
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceEmbeddingGenerator.cs (2)
136byte[] bytes = ArrayPool<byte>.Shared.Rent(Base64.GetMaxDecodedFromUtf8Length(base64.Length)); 159ArrayPool<byte>.Shared.Return(bytes);
Microsoft.Extensions.AI.OpenAI (14)
src\Shared\ServerSentEvents\ArrayBuffer.cs (4)
46: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 139_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
src\Shared\ServerSentEvents\Helpers.cs (2)
98byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 106ArrayPool<byte>.Shared.Return(sharedBuffer);
src\Shared\ServerSentEvents\SseParser_1.cs (8)
120_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 180ArrayPool<byte>.Shared.Return(_lineBuffer); 183ArrayPool<byte>.Shared.Return(_dataBuffer); 200_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 260ArrayPool<byte>.Shared.Return(_lineBuffer); 263ArrayPool<byte>.Shared.Return(_dataBuffer); 561buffer = ArrayPool<byte>.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize)); 565ArrayPool<byte>.Shared.Return(toReturn);
Microsoft.Extensions.Caching.Hybrid (27)
Internal\BufferChunk.cs (1)
80ArrayPool<byte>.Shared.Return(OversizedArray!);
Internal\DefaultHybridCache.L2.cs (5)
114byte[] oversized = ArrayPool<byte>.Shared.Rent(sizeof(long)); 121ArrayPool<byte>.Shared.Return(oversized); 132ArrayPool<byte>.Shared.Return(oversized); 228byte[] oversized = ArrayPool<byte>.Shared.Rent(maxLength); 235ArrayPool<byte>.Shared.Return(oversized);
Internal\DefaultHybridCache.StampedeStateT.cs (4)
556Span<byte> byteBuffer = maxBytes <= 128 ? stackalloc byte[128] : (leasedBytes = ArrayPool<byte>.Shared.Rent(maxBytes)); 557Span<char> charBuffer = maxChars <= 128 ? stackalloc char[128] : (leasedChars = ArrayPool<char>.Shared.Rent(maxChars)); 597ArrayPool<char>.Shared.Return(leasedChars); 598ArrayPool<byte>.Shared.Return(leasedBytes);
Internal\HybridCachePayload.cs (6)
283string[] newBuffer = ArrayPool<string>.Shared.Rent(Math.Max(4, pendingTagsCount * 2)); 285ArrayPool<string>.Shared.Return(pendingTagBuffer); 334ArrayPool<char>.Shared.Return(scratch); 335ArrayPool<string>.Shared.Return(pendingTagBuffer); 353ArrayPool<char>.Shared.Return(scratch); 354scratch = ArrayPool<char>.Shared.Rent(maxChars);
Internal\InbuiltTypeSerializer.cs (4)
43byte[] oversized = ArrayPool<byte>.Shared.Rent(length); 46ArrayPool<byte>.Shared.Return(oversized); 57byte[] oversized = ArrayPool<byte>.Shared.Rent(length); 61ArrayPool<byte>.Shared.Return(oversized);
Internal\RecyclableArrayBufferWriter.cs (3)
76ArrayPool<T>.Shared.Return(tmp); 193_buffer = ArrayPool<T>.Shared.Rent(newSize); 197ArrayPool<T>.Shared.Return(oldArray);
Internal\TagSet.cs (4)
137string[] oversized = ArrayPool<string>.Shared.Rent(8); 145string[] bigger = ArrayPool<string>.Shared.Rent(count * 2); 147ArrayPool<string>.Shared.Return(oversized); 162ArrayPool<string>.Shared.Return(oversized);
Microsoft.Extensions.Caching.Hybrid.Tests (11)
BufferReleaseTests.cs (4)
132var arr = ArrayPool<byte>.Shared.Rent(HybridCachePayload.GetMaxBytes(key, TagSet.Empty, writer.CommittedBytes)); 135ArrayPool<byte>.Shared.Return(arr); 195var arr = ArrayPool<byte>.Shared.Rent(HybridCachePayload.GetMaxBytes(key, TagSet.Empty, writer.CommittedBytes)); 198ArrayPool<byte>.Shared.Return(arr);
PayloadTests.cs (7)
48var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 78var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 112var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 142var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 178var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 232var oversized = ArrayPool<byte>.Shared.Rent(maxLen); 259var oversized = ArrayPool<byte>.Shared.Rent(maxLen);
Microsoft.Extensions.Caching.SqlServer (4)
DatabaseOperations.cs (2)
336lease ??= ArrayPool<byte>.Shared.Rent(DefaultPageSize); 357ArrayPool<byte>.Shared.Return(lease);
SqlServerCache.cs (2)
250lease = ArrayPool<byte>.Shared.Rent(length); 259ArrayPool<byte>.Shared.Return(lease);
Microsoft.Extensions.Caching.StackExchangeRedis (2)
RedisCache.cs (2)
141lease = ArrayPool<byte>.Shared.Rent(length); 150ArrayPool<byte>.Shared.Return(lease);
Microsoft.Extensions.Compliance.Abstractions (3)
src\Shared\RentedSpan\RentedSpan.cs (3)
23/// is too large to fix on the stack, it is allocated from <see cref="ArrayPool{T}"/>. 57_rentedBuffer = ArrayPool<T>.Shared.Rent(length); 81ArrayPool<T>.Shared.Return(_rentedBuffer);
Microsoft.Extensions.DependencyModel (6)
DependencyContextJsonReader.cs (6)
35ArrayPool<byte>.Shared.Return(buffer.Array!); 67rented = ArrayPool<byte>.Shared.Rent(checked((int)expectedLength)); 71rented = ArrayPool<byte>.Shared.Rent(UnseekableStreamInitialRentSize); 103rented = ArrayPool<byte>.Shared.Rent(checked(toReturn.Length * 2)); 106ArrayPool<byte>.Shared.Return(toReturn, clearArray: true); 121ArrayPool<byte>.Shared.Return(rented);
Microsoft.Extensions.Diagnostics.ResourceMonitoring (5)
Linux\OSFileSystem.cs (2)
59Memory<byte> buffer = ArrayPool<byte>.Shared.Rent(MaxStackalloc); 108ArrayPool<byte>.Shared.Return(arraySegment.Array);
src\Shared\RentedSpan\RentedSpan.cs (3)
23/// is too large to fix on the stack, it is allocated from <see cref="ArrayPool{T}"/>. 57_rentedBuffer = ArrayPool<T>.Shared.Rent(length); 81ArrayPool<T>.Shared.Return(_rentedBuffer);
Microsoft.Extensions.Http.Diagnostics (2)
Logging\Internal\HttpRequestReader.cs (1)
177var routeParams = ArrayPool<HttpRouteParameter>.Shared.Rent(routeSegments.ParameterCount);
Logging\Internal\LogRecord.cs (1)
82ArrayPool<HttpRouteParameter>.Shared.Return(PathParameters);
Microsoft.Extensions.Logging.Abstractions (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
Microsoft.Extensions.Logging.Console (6)
JsonConsoleFormatter.cs (2)
106var logMessageBuffer = ArrayPool<char>.Shared.Rent(Encoding.UTF8.GetMaxCharCount(messageBytes.Length)); 126ArrayPool<char>.Shared.Return(logMessageBuffer);
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
Microsoft.Extensions.Options.Contextual (2)
Internal\ContextualOptionsFactory.cs (2)
78var loadTasks = ArrayPool<ValueTask<IConfigureContextualOptions<TOptions>>>.Shared.Rent(_loaders.Length); 118ArrayPool<ValueTask<IConfigureContextualOptions<TOptions>>>.Shared.Return(loadTasks);
Microsoft.Extensions.ServiceDiscovery.Dns (13)
Resolver\DnsDataReader.cs (1)
127ArrayPool<byte>.Shared.Return(MessageBuffer.Array);
Resolver\DnsResolver.cs (10)
690byte[] buffer = ArrayPool<byte>.Shared.Rent(2048); 713ArrayPool<byte>.Shared.Return(buffer); 720var buffer = ArrayPool<byte>.Shared.Rent(512); 762ArrayPool<byte>.Shared.Return(buffer); 769var buffer = ArrayPool<byte>.Shared.Rent(8 * 1024); 801var largerBuffer = ArrayPool<byte>.Shared.Rent(responseLength + 2); 803ArrayPool<byte>.Shared.Return(buffer); 826ArrayPool<byte>.Shared.Return(buffer); 896byte[] buffer = ArrayPool<byte>.Shared.Rent(256); 927ArrayPool<byte>.Shared.Return(buffer);
Resolver\DnsResponse.cs (1)
34ArrayPool<byte>.Shared.Return(RawMessageBytes.Array);
Resolver\EncodedDomainName.cs (1)
77ArrayPool<byte>.Shared.Return(_pooledBuffer);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests (8)
Resolver\LoopbackDnsServer.cs (8)
54byte[] buffer = ArrayPool<byte>.Shared.Rent(512); 66ArrayPool<byte>.Shared.Return(buffer); 86byte[] buffer = ArrayPool<byte>.Shared.Rent(8 * 1024); 109ArrayPool<byte>.Shared.Return(buffer); 165byte[] buffer = ArrayPool<byte>.Shared.Rent(512); 178ArrayPool<byte>.Shared.Return(buffer); 209byte[] buffer = ArrayPool<byte>.Shared.Rent(512); 217ArrayPool<byte>.Shared.Return(buffer);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (4)
Fuzzers\EncodedDomainNameFuzzer.cs (2)
10byte[] buffer = ArrayPool<byte>.Shared.Rent(data.Length); 29ArrayPool<byte>.Shared.Return(buffer);
Fuzzers\WriteDomainNameRoundTripFuzzer.cs (2)
16byte[] buffer = ArrayPool<byte>.Shared.Rent(data.Length * 2); 45ArrayPool<byte>.Shared.Return(buffer);
Microsoft.Extensions.Telemetry (9)
Logging\JustInTimeRedactor.cs (6)
101a = ArrayPool<char>.Shared.Rent(maxLenToRedact); 131a = ArrayPool<char>.Shared.Rent(maxLenToRedact); 157var t = ArrayPool<char>.Shared.Rent(redactedLen); 160ArrayPool<char>.Shared.Return(t); 167ArrayPool<char>.Shared.Return(a); 177ArrayPool<char>.Shared.Return(a);
src\Shared\RentedSpan\RentedSpan.cs (3)
23/// is too large to fix on the stack, it is allocated from <see cref="ArrayPool{T}"/>. 57_rentedBuffer = ArrayPool<T>.Shared.Rent(length); 81ArrayPool<T>.Shared.Return(_rentedBuffer);
Microsoft.JSInterop (5)
Infrastructure\DotNetDispatcher.cs (2)
223var buffer = ArrayPool<byte>.Shared.Rent(count); 283ArrayPool<byte>.Shared.Return(buffer);
src\Components\Shared\src\ArrayBuilder.cs (3)
38private readonly ArrayPool<T> _arrayPool; 45public ArrayBuilder(int minCapacity = 32, ArrayPool<T> arrayPool = null) 47_arrayPool = arrayPool ?? ArrayPool<T>.Shared;
Microsoft.ML.Core (2)
Utilities\Stream.cs (2)
698byte[] rentedArray = ArrayPool<byte>.Shared.Rent(maxChunkSizeInBytes); 723ArrayPool<byte>.Shared.Return(rentedArray);
Microsoft.ML.ImageAnalytics (2)
ImageLoader.cs (2)
333var bufferPool = ArrayPool<byte>.Shared;
Microsoft.ML.Tokenizers (180)
Model\BPETokenizer.cs (14)
836byte[] bytes = ArrayPool<byte>.Shared.Rent(BufferLength << 1); 870ArrayPool<byte>.Shared.Return(bytes); 1322tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 1325mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 1364ArrayPool<char>.Shared.Return(tokenBuffer); 1366ArrayPool<int>.Shared.Return(mappingBuffer); 1435tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 1438mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 1484ArrayPool<char>.Shared.Return(tokenBuffer); 1486ArrayPool<int>.Shared.Return(mappingBuffer); 1515tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 1518mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 1566ArrayPool<char>.Shared.Return(tokenBuffer); 1568ArrayPool<int>.Shared.Return(mappingBuffer);
Model\CodeGenTokenizer.cs (24)
347mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 411ArrayPool<char>.Shared.Return(mutatedInputText); 455tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 458mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 477ArrayPool<char>.Shared.Return(tokenBuffer); 479ArrayPool<int>.Shared.Return(mappingBuffer); 604mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 662ArrayPool<char>.Shared.Return(mutatedInputText); 823mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 874ArrayPool<char>.Shared.Return(mutatedInputText); 960mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 1008ArrayPool<char>.Shared.Return(mutatedInputText); 1138tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 1141mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 1161ArrayPool<char>.Shared.Return(tokenBuffer); 1163ArrayPool<int>.Shared.Return(mappingBuffer); 1202tokenBuffer = ArrayPool<char>.Shared.Rent(destinationMaxSize); 1205mappingBuffer = ArrayPool<int>.Shared.Rent(destinationMaxSize); 1225ArrayPool<char>.Shared.Return(tokenBuffer); 1227ArrayPool<int>.Shared.Return(mappingBuffer); 1253byte[] bytes = ArrayPool<byte>.Shared.Rent(128); 1318ArrayPool<byte>.Shared.Return(bytes); 1613BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 1677ArrayPool<BpeSymbol>.Shared.Return(symbols);
Model\EnglishRobertaTokenizer.cs (22)
283char[] buffer = ArrayPool<char>.Shared.Rent(v.Length); 296ArrayPool<char>.Shared.Return(buffer); 363char[] token = ArrayPool<char>.Shared.Rent(text.Length); 364int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 381ArrayPool<char>.Shared.Return(token); 382ArrayPool<int>.Shared.Return(indexMapping); 388ArrayPool<char>.Shared.Return(token); 389ArrayPool<int>.Shared.Return(indexMapping); 395ArrayPool<char>.Shared.Return(token); 396ArrayPool<int>.Shared.Return(indexMapping); 675char[] token = ArrayPool<char>.Shared.Rent(text.Length); 676int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 693ArrayPool<char>.Shared.Return(token); 694ArrayPool<int>.Shared.Return(indexMapping); 701ArrayPool<char>.Shared.Return(token); 702ArrayPool<int>.Shared.Return(indexMapping); 720char[] token = ArrayPool<char>.Shared.Rent(text.Length); 721int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 738ArrayPool<char>.Shared.Return(token); 739ArrayPool<int>.Shared.Return(indexMapping); 746ArrayPool<char>.Shared.Return(token); 747ArrayPool<int>.Shared.Return(indexMapping);
Model\SentencePieceBaseModel.cs (8)
265ArrayPool<byte>.Shared.Return(bytesPoolArray); 270ArrayPool<char>.Shared.Return(charPoolArray); 282charPoolArray ??= ArrayPool<char>.Shared.Rent(Math.Max(len, ApproximatedMaxEncodedBytesCount >> 1)); 304bytesPoolArray ??= ArrayPool<byte>.Shared.Rent(ApproximatedMaxEncodedBytesCount); 566ArrayPool<byte>.Shared.Return(bytesPoolArray); 571ArrayPool<char>.Shared.Return(charPoolArray); 620charPoolArray ??= ArrayPool<char>.Shared.Rent(Math.Max(len, ApproximatedMaxEncodedBytesCount >> 1)); 658bytesPoolArray ??= ArrayPool<byte>.Shared.Rent(ApproximatedMaxEncodedBytesCount);
Model\SentencePieceBpeModel.cs (18)
152BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 199ArrayPool<BpeSymbol>.Shared.Return(symbols); 231arrayPoolArray = ArrayPool<byte>.Shared.Rent(len); 252ArrayPool<byte>.Shared.Return(arrayPoolArray); 435BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 464ArrayPool<BpeSymbol>.Shared.Return(symbols); 478ArrayPool<BpeSymbol>.Shared.Return(symbols); 491ArrayPool<BpeSymbol>.Shared.Return(symbols); 531arrayPoolArray = ArrayPool<byte>.Shared.Rent(len); 556ArrayPool<byte>.Shared.Return(arrayPoolArray); 703BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 756ArrayPool<BpeSymbol>.Shared.Return(symbols); 794arrayPoolArray = ArrayPool<byte>.Shared.Rent(len); 815ArrayPool<byte>.Shared.Return(arrayPoolArray); 972BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 1032ArrayPool<BpeSymbol>.Shared.Return(symbols); 1070arrayPoolArray = ArrayPool<byte>.Shared.Rent(len); 1091ArrayPool<byte>.Shared.Return(arrayPoolArray);
Model\SentencePieceUnigramModel.cs (40)
112int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 115char[] normalizedString = ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 126ArrayPool<char>.Shared.Return(normalizedString); 127ArrayPool<int>.Shared.Return(buffer); 149char[] utf16NormalizedString = ArrayPool<char>.Shared.Rent(normalizedString.Length << 1); 151ArrayPool<char>.Shared.Return(normalizedString); 166char[] utf16NormalizedString = ArrayPool<char>.Shared.Rent(normalizedString.Length << 1); 168ArrayPool<char>.Shared.Return(normalizedString); 313ArrayPool<byte>.Shared.Return(normalizedArrayPool); 345BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 405ArrayPool<BestPathNode>.Shared.Return(bestPathEndsAt); 408ArrayPool<byte>.Shared.Return(normalizedArrayPool); 584int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 587char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 605ArrayPool<char>.Shared.Return(normalizedString); 608ArrayPool<int>.Shared.Return(buffer); 627ArrayPool<byte>.Shared.Return(normalizedArrayPool); 785BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 808unknownTokensTracking = ArrayPool<(int IdsIndex, int Utf8Index, int Utf8Length)>.Shared.Rent(10); 821ArrayPool<BestPathNode>.Shared.Return(bestPathEndsAt); 857ArrayPool<byte>.Shared.Return(normalizedArrayPool); 931ArrayPool<(int IdsIndex, int Utf8Index, int Utf8Length)>.Shared.Return(unknownTokensTracking); 936ArrayPool<byte>.Shared.Return(normalizedArrayPool); 974int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 977char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 995ArrayPool<char>.Shared.Return(normalizedString); 998ArrayPool<int>.Shared.Return(buffer); 1116BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 1122(int Id, int UtfStartOffset, int Utf8Length)[] ids = ArrayPool<(int Id, int UtfStartOffset, int Utf8Length)>.Shared.Rent(bestPathEndsAt.Length); 1142ArrayPool<BestPathNode>.Shared.Return(bestPathEndsAt); 1155ArrayPool<(int Id, int UtfStartOffset, int Utf8Length)>.Shared.Return(ids); 1159ArrayPool<byte>.Shared.Return(normalizedArrayPool); 1197ArrayPool<(int Id, int UtfStartOffset, int Utf8Length)>.Shared.Return(ids); 1206ArrayPool<byte>.Shared.Return(normalizedArrayPool); 1241int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 1244char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 1262ArrayPool<int>.Shared.Return(buffer); 1367BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 1420ArrayPool<BestPathNode>.Shared.Return(bestPathEndsAt); 1423ArrayPool<byte>.Shared.Return(normalizedArrayPool);
Model\TiktokenTokenizer.cs (19)
324byte[] arrayPoolArray = arrayPoolArray = ArrayPool<byte>.Shared.Rent(utf8Length); 326Span<int> indexMappingSpan = utf8Length + 1 <= 128 ? stackalloc int[128] : (indexMappingArray = ArrayPool<int>.Shared.Rent(utf8Length + 1)); 332ArrayPool<byte>.Shared.Return(arrayPoolArray); 335ArrayPool<int>.Shared.Return(indexMappingArray); 441byte[] arrayPoolArray = arrayPoolArray = ArrayPool<byte>.Shared.Rent(utf8Length); 443Span<int> indexMappingSpan = utf8Length + 1 <= 128 ? stackalloc int[128] : (indexMappingArray = ArrayPool<int>.Shared.Rent(utf8Length + 1)); 449ArrayPool<byte>.Shared.Return(arrayPoolArray); 452ArrayPool<int>.Shared.Return(indexMappingArray); 606byte[] arrayPoolArray = arrayPoolArray = ArrayPool<byte>.Shared.Rent(utf8Length); 608Span<int> indexMappingSpan = utf8Length + 1 <= 128 ? stackalloc int[128] : (indexMappingArray = ArrayPool<int>.Shared.Rent(utf8Length + 1)); 614ArrayPool<byte>.Shared.Return(arrayPoolArray); 617ArrayPool<int>.Shared.Return(indexMappingArray); 732byte[] arrayPoolArray = arrayPoolArray = ArrayPool<byte>.Shared.Rent(utf8Length); 734Span<int> indexMappingSpan = utf8Length + 1 <= 128 ? stackalloc int[128] : (indexMappingArray = ArrayPool<int>.Shared.Rent(utf8Length + 1)); 740ArrayPool<byte>.Shared.Return(arrayPoolArray); 743ArrayPool<int>.Shared.Return(indexMappingArray); 835ArrayPool<byte>.Shared.Return(arrayPoolArray); 841byte[] tmp = ArrayPool<byte>.Shared.Rent(Math.Max(utf8Bytes.Length * 2, requiredCapacity)); 847ArrayPool<byte>.Shared.Return(toReturn);
Model\WordPieceTokenizer.cs (4)
324char[]? arrayPool = maxLength <= 250 ? null : ArrayPool<char>.Shared.Rent(maxLength); 378ArrayPool<char>.Shared.Return(arrayPool); 464char[]? arrayPool = maxLength <= 250 ? null : ArrayPool<char>.Shared.Rent(maxLength); 528ArrayPool<char>.Shared.Return(arrayPool);
Normalizer\BertNormalizer.cs (2)
42char[] buffer = ArrayPool<char>.Shared.Rent(original.Length); 117ArrayPool<char>.Shared.Return(buffer);
Normalizer\LowerCaseNormalizer.cs (2)
45char[] arrayPoolArray = ArrayPool<char>.Shared.Rent(original.Length); 51ArrayPool<char>.Shared.Return(arrayPoolArray);
Normalizer\SentencePieceNormalizer.cs (2)
137buffer = ArrayPool<char>.Shared.Rent(spanLength); 196ArrayPool<char>.Shared.Return(buffer);
Normalizer\UpperCaseNormalizer.cs (2)
45char[] arrayPoolArray = ArrayPool<char>.Shared.Rent(original.Length); 51ArrayPool<char>.Shared.Return(arrayPoolArray);
PreTokenizer\CompositePreTokenizer.cs (2)
149char[] buffer = ArrayPool<char>.Shared.Rent(text.Length); 154ArrayPool<char>.Shared.Return(buffer);
Tokenizer.cs (4)
381char[] destination = ArrayPool<char>.Shared.Rent( 393ArrayPool<char>.Shared.Return(destination); 407ArrayPool<char>.Shared.Return(destination); 408destination = ArrayPool<char>.Shared.Rent((int)newSize);
Utils\BytePairEncoder.cs (2)
27(arrayPoolArray = ArrayPool<(int, int)>.Shared.Rent(requiredLength)); 113ArrayPool<(int, int)>.Shared.Return(arrayPoolArray);
Utils\DoubleArrayTrie.cs (3)
751ArrayPool<byte>.Shared.Return(array); 754array = ArrayPool<byte>.Shared.Rent(encodingLength * 2); 765ArrayPool<byte>.Shared.Return(array);
Utils\Helpers.cs (4)
24T[] tmp = ArrayPool<T>.Shared.Rent(Math.Max(arrayPoolArray.Length * 2, requiredCapacity)); 26ArrayPool<T>.Shared.Return(arrayPoolArray); 34T[] newPoolArray = ArrayPool<T>.Shared.Rent(newSize); 39ArrayPool<T>.Shared.Return(poolArray);
Utils\OrdinalUtf8StringComparer.cs (4)
63bytes1 = ArrayPool<byte>.Shared.Rent(requiredLength1); 69bytes2 = ArrayPool<byte>.Shared.Rent(requiredLength2); 80ArrayPool<byte>.Shared.Return(bytes1); 85ArrayPool<byte>.Shared.Return(bytes2);
Utils\ValueStringBuilder.cs (4)
30_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 405char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 413ArrayPool<char>.Shared.Return(toReturn); 424ArrayPool<char>.Shared.Return(toReturn);
Microsoft.ML.Tokenizers.Tests (11)
src\Microsoft.ML.Tokenizers\Utils\DoubleArrayTrie.cs (3)
751ArrayPool<byte>.Shared.Return(array); 754array = ArrayPool<byte>.Shared.Rent(encodingLength * 2); 765ArrayPool<byte>.Shared.Return(array);
src\Microsoft.ML.Tokenizers\Utils\Helpers.cs (4)
24T[] tmp = ArrayPool<T>.Shared.Rent(Math.Max(arrayPoolArray.Length * 2, requiredCapacity)); 26ArrayPool<T>.Shared.Return(arrayPoolArray); 34T[] newPoolArray = ArrayPool<T>.Shared.Rent(newSize); 39ArrayPool<T>.Shared.Return(poolArray);
src\Microsoft.ML.Tokenizers\Utils\OrdinalUtf8StringComparer.cs (4)
63bytes1 = ArrayPool<byte>.Shared.Rent(requiredLength1); 69bytes2 = ArrayPool<byte>.Shared.Rent(requiredLength2); 80ArrayPool<byte>.Shared.Return(bytes1); 85ArrayPool<byte>.Shared.Return(bytes2);
Microsoft.Net.Http.Headers (4)
ContentDispositionHeaderValue.cs (4)
552: bufferFromPool = ArrayPool<byte>.Shared.Rent(requiredLength); 567ArrayPool<byte>.Shared.Return(bufferFromPool); 720unescapedBytes = ArrayPool<byte>.Shared.Rent(dataString.Length); 756ArrayPool<byte>.Shared.Return(unescapedBytes);
mscorlib (1)
mscorlib.cs (1)
33[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ArrayPool<>))]
netstandard (1)
netstandard.cs (1)
60[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ArrayPool<>))]
PresentationCore (3)
System\Windows\Media\RenderData.cs (3)
456_buffer = ArrayPool<byte>.Shared.Rent(cbRequiredSize); 473byte[] newBuffer = ArrayPool<byte>.Shared.Rent(newSize); 486ArrayPool<byte>.Shared.Return(oldBuffer);
PresentationFramework (2)
System\Windows\Markup\Baml2006\Baml2006Reader.cs (2)
1114byte[] pooledArray = ArrayPool<byte>.Shared.Rent(toRead); 1120ArrayPool<byte>.Shared.Return(pooledArray);
Roslyn.Diagnostics.Analyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Shared (15)
RentedSpan\RentedSpan.cs (3)
23/// is too large to fix on the stack, it is allocated from <see cref="ArrayPool{T}"/>. 57_rentedBuffer = ArrayPool<T>.Shared.Rent(length); 81ArrayPool<T>.Shared.Return(_rentedBuffer);
ServerSentEvents\ArrayBuffer.cs (4)
46: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 139_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
ServerSentEvents\SseParser_1.cs (8)
120_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 180ArrayPool<byte>.Shared.Return(_lineBuffer); 183ArrayPool<byte>.Shared.Return(_dataBuffer); 200_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 260ArrayPool<byte>.Shared.Return(_lineBuffer); 263ArrayPool<byte>.Shared.Return(_dataBuffer); 561buffer = ArrayPool<byte>.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize)); 565ArrayPool<byte>.Shared.Return(toReturn);
System.Buffers (1)
System.Buffers.cs (1)
4[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ArrayPool<>))]
System.Collections.Immutable (22)
System\Collections\Frozen\FrozenHashTable.cs (4)
59int[] arrayPoolBuckets = ArrayPool<int>.Shared.Rent(numBuckets + hashCodes.Length); 114ArrayPool<int>.Shared.Return(arrayPoolBuckets); 214int[] seenBuckets = ArrayPool<int>.Shared.Rent((maxNumBuckets / BitsPerInt32) + 1); 269ArrayPool<int>.Shared.Return(seenBuckets);
System\Collections\Frozen\FrozenSetInternalBase.cs (2)
200(rentedArray = ArrayPool<int>.Shared.Rent(intArrayLength)); 233ArrayPool<int>.Shared.Return(rentedArray);
System\Collections\Frozen\Int32\Int32FrozenDictionary.cs (2)
31int[] arrayPoolHashCodes = ArrayPool<int>.Shared.Rent(entries.Length); 47ArrayPool<int>.Shared.Return(arrayPoolHashCodes);
System\Collections\Frozen\Int32\Int32FrozenSet.cs (2)
25int[] entries = ArrayPool<int>.Shared.Rent(count); 30ArrayPool<int>.Shared.Return(entries);
System\Collections\Frozen\ItemsFrozenSet.cs (2)
26int[] arrayPoolHashCodes = ArrayPool<int>.Shared.Rent(entries.Length); 42ArrayPool<int>.Shared.Return(arrayPoolHashCodes);
System\Collections\Frozen\KeysAndValuesFrozenDictionary.cs (2)
28int[] arrayPoolHashCodes = ArrayPool<int>.Shared.Rent(entries.Length); 45ArrayPool<int>.Shared.Return(arrayPoolHashCodes);
System\Collections\Frozen\String\LengthBuckets.cs (4)
47int[] buckets = ArrayPool<int>.Shared.Rent(arraySize); 78ArrayPool<int>.Shared.Return(buckets); 86ArrayPool<int>.Shared.Return(buckets); 97ArrayPool<int>.Shared.Return(buckets);
System\Collections\Frozen\String\OrdinalStringFrozenDictionary.cs (2)
43int[] arrayPoolHashCodes = ArrayPool<int>.Shared.Rent(keys.Length); 60ArrayPool<int>.Shared.Return(arrayPoolHashCodes);
System\Collections\Frozen\String\OrdinalStringFrozenSet.cs (2)
34int[] arrayPoolHashCodes = ArrayPool<int>.Shared.Rent(entries.Length); 50ArrayPool<int>.Shared.Return(arrayPoolHashCodes);
System.Console (6)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\IO\CachedConsoleStream.cs (2)
29Span<char> charSpan = (uint)maxCharCount <= 512 ? stackalloc char[512] : (pooledBuffer = ArrayPool<char>.Shared.Rent(maxCharCount)); 42ArrayPool<char>.Shared.Return(pooledBuffer);
System.Diagnostics.DiagnosticSource (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System.Diagnostics.Process (15)
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.TryReadStatusFile.cs (4)
143byte[] bytes = ArrayPool<byte>.Shared.Rent(4096); 162byte[] temp = ArrayPool<byte>.Shared.Rent(bytes.Length * 2); 166ArrayPool<byte>.Shared.Return(toReturn); 177ArrayPool<byte>.Shared.Return(bytes);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (2)
64ArrayPool<byte>.Shared.Return(arrayBuffer); 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
30_arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(maxSize); 46ArrayPool<byte>.Shared.Return(toReturn);
System\Diagnostics\Process.Linux.cs (3)
287byte[] tmp = ArrayPool<byte>.Shared.Rent((int)newLength); 293ArrayPool<byte>.Shared.Return(toReturn); 341ArrayPool<byte>.Shared.Return(rentedArray);
System.Formats.Asn1 (2)
src\libraries\Common\src\System\Security\Cryptography\CryptoPool.cs (2)
13internal static byte[] Rent(int minimumLength) => ArrayPool<byte>.Shared.Rent(minimumLength); 37ArrayPool<byte>.Shared.Return(array, clearWholeArray);
System.Formats.Cbor (2)
System\Formats\Cbor\Writer\CborWriter.cs (2)
16private static readonly ArrayPool<byte> s_bufferPool = ArrayPool<byte>.Create();
System.Formats.Nrbf (2)
System\Formats\Nrbf\Utils\TypeNameHelpers.cs (2)
134ArrayPool<char>.Shared.Return(assemblyQualifiedName.Array!); 209char[] rented = ArrayPool<char>.Shared.Rent(length);
System.Formats.Tar (33)
src\libraries\Common\src\System\IO\Archiving.Utils.cs (2)
24buffer = ArrayPool<char>.Shared.Rent(newCapacity); 25ArrayPool<char>.Shared.Return(oldBuffer);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\Formats\Tar\TarHeader.Read.cs (10)
45byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength: TarHelpers.RecordSize); 56ArrayPool<byte>.Shared.Return(rented); 587(buffer = ArrayPool<byte>.Shared.Rent((int)size)); 595ArrayPool<byte>.Shared.Return(buffer); 609byte[] buffer = ArrayPool<byte>.Shared.Rent((int)_size); 615ArrayPool<byte>.Shared.Return(buffer); 658(buffer = ArrayPool<byte>.Shared.Rent((int)size)); 666ArrayPool<byte>.Shared.Return(buffer); 681byte[] buffer = ArrayPool<byte>.Shared.Rent((int)_size); 687ArrayPool<byte>.Shared.Return(buffer);
System\Formats\Tar\TarHeader.Write.cs (5)
854byte[] buffer = ArrayPool<byte>.Shared.Rent(paddingAfterData); 859ArrayPool<byte>.Shared.Return(buffer); 900ArrayPool<byte>.Shared.Return(buffer); 902span = buffer = ArrayPool<byte>.Shared.Rent(length); 923ArrayPool<byte>.Shared.Return(buffer);
System\Formats\Tar\TarHelpers.cs (8)
60byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToDiscard)); 67ArrayPool<byte>.Shared.Return(buffer); 82byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToDiscard)); 89ArrayPool<byte>.Shared.Return(buffer); 96byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToCopy)); 104ArrayPool<byte>.Shared.Return(buffer); 112byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToCopy)); 121ArrayPool<byte>.Shared.Return(buffer);
System\Formats\Tar\TarWriter.cs (4)
337byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength: TarHelpers.RecordSize); 354ArrayPool<byte>.Shared.Return(rented); 375byte[] twoEmptyRecords = ArrayPool<byte>.Shared.Rent(TwoRecordSize); 380ArrayPool<byte>.Shared.Return(twoEmptyRecords);
System.IO.Compression (18)
System\IO\Compression\DeflateZLib\DeflateStream.cs (6)
144_buffer = ArrayPool<byte>.Shared.Rent(DefaultBufferSize); 738ArrayPool<byte>.Shared.Return(buffer); 791ArrayPool<byte>.Shared.Return(buffer); 928_arrayPoolBuffer = ArrayPool<byte>.Shared.Rent(bufferSize); 963ArrayPool<byte>.Shared.Return(_arrayPoolBuffer); 997ArrayPool<byte>.Shared.Return(_arrayPoolBuffer);
System\IO\Compression\ZipBlocks.Async.cs (4)
123byte[] arrayPoolBuffer = ArrayPool<byte>.Shared.Rent(extraFieldLength); 139ArrayPool<byte>.Shared.Return(arrayPoolBuffer); 195arrayPoolBuffer = ArrayPool<byte>.Shared.Rent(dynamicHeaderSize); 218ArrayPool<byte>.Shared.Return(arrayPoolBuffer);
System\IO\Compression\ZipBlocks.cs (4)
598byte[]? arrayPoolBuffer = extraFieldLength > StackAllocationThreshold ? ArrayPool<byte>.Shared.Rent(extraFieldLength) : null; 611ArrayPool<byte>.Shared.Return(arrayPoolBuffer); 815arrayPoolBuffer = ArrayPool<byte>.Shared.Rent(dynamicHeaderSize); 838ArrayPool<byte>.Shared.Return(arrayPoolBuffer);
System\IO\Compression\ZipHelper.Async.cs (2)
47byte[] buffer = ArrayPool<byte>.Shared.Rent(BackwardsSeekingBufferSize); 94ArrayPool<byte>.Shared.Return(buffer);
System\IO\Compression\ZipHelper.cs (2)
118byte[] buffer = ArrayPool<byte>.Shared.Rent(BackwardsSeekingBufferSize); 165ArrayPool<byte>.Shared.Return(buffer);
System.IO.Compression.Brotli (2)
System\IO\Compression\BrotliStream.cs (2)
59_buffer = ArrayPool<byte>.Shared.Rent(DefaultInternalBufferSize); 133ArrayPool<byte>.Shared.Return(buffer);
System.IO.Compression.ZipFile (2)
src\libraries\Common\src\System\IO\Archiving.Utils.cs (2)
24buffer = ArrayPool<char>.Shared.Rent(newCapacity); 25ArrayPool<char>.Shared.Return(oldBuffer);
System.IO.FileSystem.Watcher (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System.IO.Packaging (2)
System\IO\Packaging\InterleavedZipPackagePartStream.cs (2)
547byte[] readBuffer = ArrayPool<byte>.Shared.Rent(BufferSize); 563ArrayPool<byte>.Shared.Return(readBuffer);
System.IO.Pipelines (4)
System\IO\Pipelines\BufferSegment.cs (1)
84ArrayPool<byte>.Shared.Return(_array);
System\IO\Pipelines\Pipe.cs (1)
253segment.SetOwnedMemory(ArrayPool<byte>.Shared.Rent(sizeToRequest));
System\IO\Pipelines\StreamPipeReader.cs (1)
528nextSegment.SetOwnedMemory(ArrayPool<byte>.Shared.Rent(sizeToRequest));
System\IO\Pipelines\StreamPipeWriter.cs (1)
167newSegment.SetOwnedMemory(ArrayPool<byte>.Shared.Rent(sizeToRequest));
System.Linq (4)
System\Linq\SegmentedArrayBuilder.cs (4)
74ArrayPool<T>.Shared.Return(segment); 80ArrayPool<T>.Shared.Return(currentSegment); 93ArrayPool<T>.Shared.Return(segment); 355_currentSegment = _segments[_segmentsCount] = ArrayPool<T>.Shared.Rent(newSegmentLength);
System.Memory (6)
System\Buffers\ArrayMemoryPool.ArrayMemoryPoolBuffer.cs (2)
14_array = ArrayPool<T>.Shared.Rent(size); 34ArrayPool<T>.Shared.Return(array);
System\Text\EncodingExtensions.cs (4)
178byte[] rentedArray = ArrayPool<byte>.Shared.Rent(byteCountThisIteration); 205ArrayPool<byte>.Shared.Return(array); 365char[] rentedArray = ArrayPool<char>.Shared.Rent(charCountThisIteration); 391ArrayPool<char>.Shared.Return(array);
System.Net.Http (37)
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\QPack\QPackDecoder.cs (2)
128private static ArrayPool<byte> Pool => ArrayPool<byte>.Shared;
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (3)
53ArrayPool<byte>.Shared.Return(toReturn); 114ArrayPool<byte>.Shared.Return(toReturn); 231_blocks[allocatedBlockCount++] = ArrayPool<byte>.Shared.Rent(BlockSize);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\Net\Http\Headers\HeaderDescriptor.cs (2)
262char[] rented = ArrayPool<char>.Shared.Rent(input.Length); 274ArrayPool<char>.Shared.Return(rented);
System\Net\Http\Headers\HeaderUtilities.cs (2)
71byte[] utf8bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(input.Length)); 109ArrayPool<byte>.Shared.Return(utf8bytes);
System\Net\Http\HttpContent.cs (6)
173byte[] buffer = ArrayPool<byte>.Shared.Rent((int)stream.Length); 178ArrayPool<byte>.Shared.Return(buffer); 984newBuffer = ArrayPool<byte>.Shared.Rent(newBufferCapacity); 1004newBuffer = ArrayPool<byte>.Shared.Rent(newBufferCapacity); 1081ArrayPool<byte>.Shared.Return(buffer); 1092ArrayPool<byte>.Shared.Return(lastBuffer);
System\Net\Http\MultipartContent.cs (2)
651: (rentedBuffer = ArrayPool<byte>.Shared.Rent(maxLength)); 662ArrayPool<byte>.Shared.Return(rentedBuffer);
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http1.cs (2)
438HttpConnection[] stackCopy = ArrayPool<HttpConnection>.Shared.Rent(pool._associatedHttp11ConnectionCount); 463ArrayPool<HttpConnection>.Shared.Return(stackCopy);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (4)
1188byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 1218ArrayPool<byte>.Shared.Return(buffer); 1224byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 1254ArrayPool<byte>.Shared.Return(buffer);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (2)
1975byte[] pooledBuffer = ArrayPool<byte>.Shared.Rent(desiredBufferSize); 1995ArrayPool<byte>.Shared.Return(pooledBuffer);
System\Net\Http\SocketsHttpHandler\SocksHelper.cs (4)
67byte[] buffer = ArrayPool<byte>.Shared.Rent(BufferSize); 209ArrayPool<byte>.Shared.Return(buffer); 215byte[] buffer = ArrayPool<byte>.Shared.Rent(BufferSize); 316ArrayPool<byte>.Shared.Return(buffer);
System.Net.Mail (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System.Net.Ping (2)
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
30_arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(maxSize); 46ArrayPool<byte>.Shared.Return(toReturn);
System.Net.Primitives (2)
src\libraries\Common\src\System\Net\NetworkInformation\InterfaceInfoPal.Unix.cs (2)
47: (rentedBuffer = ArrayPool<byte>.Shared.Rent(bufferSize))) 70ArrayPool<byte>.Shared.Return(rentedBuffer);
System.Net.Quic (15)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs (2)
34byte[] buffer = ArrayPool<byte>.Shared.Rent(1024); 43ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (3)
53ArrayPool<byte>.Shared.Return(toReturn); 114ArrayPool<byte>.Shared.Return(toReturn); 231_blocks[allocatedBlockCount++] = ArrayPool<byte>.Shared.Rent(BlockSize);
System\Net\Quic\QuicConnection.SslConnectionOptions.cs (4)
102certDataRented = ArrayPool<byte>.Shared.Rent((int)certificateBuffer->Length); 109chainDataRented = ArrayPool<byte>.Shared.Rent((int)chainBuffer->Length); 148ArrayPool<byte>.Shared.Return(certDataRented); 153ArrayPool<byte>.Shared.Return(chainDataRented);
System\Net\Quic\QuicStream.Stream.cs (2)
118byte[] rentedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 137ArrayPool<byte>.Shared.Return(rentedBuffer);
System.Net.Security (26)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs (2)
34byte[] buffer = ArrayPool<byte>.Shared.Rent(1024); 43ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSsl.cs (4)
596byte[] buffer = ArrayPool<byte>.Shared.Rent(512); 644ArrayPool<byte>.Shared.Return(buffer); 655buffer = ArrayPool<byte>.Shared.Rent(buffer.Length * 2); 657ArrayPool<byte>.Shared.Return(oldBuffer);
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Net\Security\RC4.cs (2)
46state = ArrayPool<byte>.Shared.Rent(256); 71ArrayPool<byte>.Shared.Return(state);
src\libraries\Common\src\System\Security\Cryptography\CryptoPool.cs (2)
13internal static byte[] Rent(int minimumLength) => ArrayPool<byte>.Shared.Rent(minimumLength); 37ArrayPool<byte>.Shared.Return(array, clearWholeArray);
src\libraries\Common\src\System\Text\UrlBase64Encoding.cs (3)
18char[] base64 = ArrayPool<char>.Shared.Rent(base64Len); 30char[] urlEncoded = ArrayPool<char>.Shared.Rent(urlEncodedLen); 76ArrayPool<char>.Shared.Return(base64);
System\Net\Security\SslStream.Protocol.cs (4)
1377Payload = RentBuffer ? ArrayPool<byte>.Shared.Rent(Size) : new byte[Size]; 1391Payload = RentBuffer ? ArrayPool<byte>.Shared.Rent(Size + size) : new byte[Size + size]; 1397ArrayPool<byte>.Shared.Return(oldPayload); 1416ArrayPool<byte>.Shared.Return(toReturn);
System\Net\Security\SslStreamCertificateContext.Linux.cs (5)
292IntPtr[] issuerHandles = ArrayPool<IntPtr>.Shared.Rent(_privateIntermediateCertificates.Length + 1); 310byte[] rentedBytes = ArrayPool<byte>.Shared.Rent(Interop.Crypto.GetOcspRequestDerSize(ocspRequest)); 353ArrayPool<IntPtr>.Shared.Return(issuerHandles); 354ArrayPool<byte>.Shared.Return(rentedBytes); 355ArrayPool<char>.Shared.Return(rentedChars.Array!);
System.Net.ServerSentEvents (12)
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
System\Net\ServerSentEvents\SseParser_1.cs (8)
104_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 164ArrayPool<byte>.Shared.Return(_lineBuffer); 167ArrayPool<byte>.Shared.Return(_dataBuffer); 184_lineBuffer = ArrayPool<byte>.Shared.Rent(DefaultArrayPoolRentSize); 244ArrayPool<byte>.Shared.Return(_lineBuffer); 247ArrayPool<byte>.Shared.Return(_dataBuffer); 537buffer = ArrayPool<byte>.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize)); 541ArrayPool<byte>.Shared.Return(toReturn);
System.Net.WebSockets (20)
System\Net\WebSockets\Compression\WebSocketDeflater.cs (4)
37ArrayPool<byte>.Shared.Return(toReturn); 49_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(payload.Length, MinInitialBufferLength)); 67byte[] newBuffer = ArrayPool<byte>.Shared.Rent((int)(_buffer.Length * 1.3)); 73ArrayPool<byte>.Shared.Return(toReturn);
System\Net\WebSockets\Compression\WebSocketInflater.cs (5)
83_buffer = ArrayPool<byte>.Shared.Rent((int)Math.Min(userBufferLength, payloadLength)); 100_buffer = ArrayPool<byte>.Shared.Rent(FlushMarkerLength); 108byte[] newBuffer = ArrayPool<byte>.Shared.Rent(_available + FlushMarkerLength); 114ArrayPool<byte>.Shared.Return(toReturn); 209ArrayPool<byte>.Shared.Return(toReturn);
System\Net\WebSockets\ManagedWebSocket.cs (7)
1441byte[] closeBuffer = ArrayPool<byte>.Shared.Rent(MaxMessageHeaderLength + MaxControlPayloadLength); 1484ArrayPool<byte>.Shared.Return(closeBuffer); 1520buffer = ArrayPool<byte>.Shared.Rent(count); 1525buffer = ArrayPool<byte>.Shared.Rent(count); 1538ArrayPool<byte>.Shared.Return(buffer); 1619_sendBuffer = ArrayPool<byte>.Shared.Rent(minLength); 1630ArrayPool<byte>.Shared.Return(toReturn);
System\Net\WebSockets\WebSocket.cs (4)
43byte[] array = ArrayPool<byte>.Shared.Rent(buffer.Length); 52ArrayPool<byte>.Shared.Return(array); 72byte[] array = ArrayPool<byte>.Shared.Rent(buffer.Length); 80ArrayPool<byte>.Shared.Return(array);
System.Numerics.Tensors (11)
System\Numerics\Tensors\netcore\TensorOperation.cs (2)
2640rentedBuffer._array = ArrayPool<T>.Shared.Rent(rank); 2660ArrayPool<T>.Shared.Return(_array);
System\Numerics\Tensors\netcore\TensorShape.cs (9)
170stridesOrderArray = ArrayPool<int>.Shared.Rent(rank); 715lengthsArray = ArrayPool<nint>.Shared.Rent(rank); 738ArrayPool<nint>.Shared.Return(lengthsArray); 772intermediateLengthsArray = ArrayPool<nint>.Shared.Rent(rank); 832ArrayPool<nint>.Shared.Return(intermediateLengthsArray); 1049intermediateLengthsArray = ArrayPool<nint>.Shared.Rent(rank); 1052intermediateStridesArray = ArrayPool<nint>.Shared.Rent(rank); 1153ArrayPool<nint>.Shared.Return(intermediateLengthsArray); 1158ArrayPool<nint>.Shared.Return(intermediateStridesArray);
System.Private.CoreLib (159)
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.TryReadStatusFile.cs (4)
143byte[] bytes = ArrayPool<byte>.Shared.Rent(4096); 162byte[] temp = ArrayPool<byte>.Shared.Rent(bytes.Length * 2); 166ArrayPool<byte>.Shared.Return(toReturn); 177ArrayPool<byte>.Shared.Return(bytes);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetCwd.cs (2)
30byte[] buf = ArrayPool<byte>.Shared.Rent(bufferSize); 44ArrayPool<byte>.Shared.Return(buf);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (2)
64ArrayPool<byte>.Shared.Return(arrayBuffer); 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
30_arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(maxSize); 46ArrayPool<byte>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Buffers\ArrayPool.cs (12)
11/// Renting and returning buffers with an <see cref="ArrayPool{T}"/> can increase performance 26/// Retrieves a shared <see cref="ArrayPool{T}"/> instance. 29/// The shared pool provides a default implementation of <see cref="ArrayPool{T}"/> 39public static ArrayPool<T> Shared => s_shared; 42/// Creates a new <see cref="ArrayPool{T}"/> instance using default configuration options. 44/// <returns>A new <see cref="ArrayPool{T}"/> instance.</returns> 45public static ArrayPool<T> Create() => new ConfigurableArrayPool<T>(); 48/// Creates a new <see cref="ArrayPool{T}"/> instance using custom configuration options. 55/// <returns>A new <see cref="ArrayPool{T}"/> instance with the specified configuration options.</returns> 60public static ArrayPool<T> Create(int maxArrayLength, int maxArraysPerBucket) => 81/// <see cref="ArrayPool{T}"/> instance. 95/// returned via <see cref="Return"/> once. The default <see cref="ArrayPool{T}"/>
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlDecoder.cs (4)
169: (rented = ArrayPool<byte>.Shared.Rent(upperBound)); 177ArrayPool<byte>.Shared.Return(rented); 385: (rented = ArrayPool<byte>.Shared.Rent(upperBound)); 392ArrayPool<byte>.Shared.Return(rented);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (5)
172ArrayPool<T>.Shared.Return(toReturn, _pos); 176ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 223ArrayPool<T>.Shared.Return(toReturn, _pos); 227ArrayPool<T>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Icu.cs (4)
868: (borrowedArray = ArrayPool<byte>.Shared.Rent(sortKeyLength)); 890ArrayPool<byte>.Shared.Return(borrowedArray); 893sortKey = (borrowedArray = ArrayPool<byte>.Shared.Rent(sortKeyLength)); 920ArrayPool<byte>.Shared.Return(borrowedArray);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Nls.cs (2)
158(borrowedArr = ArrayPool<byte>.Shared.Rent(sortKeyLength)); 177ArrayPool<byte>.Shared.Return(borrowedArr);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Utf8.cs (7)
92sourceUtf16Array = ArrayPool<char>.Shared.Rent(sourceMaxCharCount); 103ArrayPool<char>.Shared.Return(sourceUtf16Array); 123prefixUtf16Array = ArrayPool<char>.Shared.Rent(prefixMaxCharCount); 135ArrayPool<char>.Shared.Return(prefixUtf16Array); 140ArrayPool<char>.Shared.Return(sourceUtf16Array); 155ArrayPool<char>.Shared.Return(prefixUtf16Array); 160ArrayPool<char>.Shared.Return(sourceUtf16Array);
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Icu.cs (4)
62: (toReturn = ArrayPool<char>.Shared.Rent(strInput.Length)); 104ArrayPool<char>.Shared.Return(temp); 107buffer = toReturn = ArrayPool<char>.Shared.Rent(realLen); 117ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Nls.cs (4)
54: (toReturn = ArrayPool<char>.Shared.Rent(strInput.Length)); 86ArrayPool<char>.Shared.Return(temp); 89buffer = toReturn = ArrayPool<char>.Shared.Rent(realLength); 110ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (2)
525byte[] buffer = ArrayPool<byte>.Shared.Rent(numBytes); 527ArrayPool<byte>.Shared.Return(buffer);
src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (10)
198rented = ArrayPool<byte>.Shared.Rent(maxByteCount); 207ArrayPool<byte>.Shared.Return(rented); 367byte[] rented = ArrayPool<byte>.Shared.Rent(value.Length * 3); // max expansion: each char -> 3 bytes 371ArrayPool<byte>.Shared.Return(rented); 392byte[] array = ArrayPool<byte>.Shared.Rent(buffer.Length); 400ArrayPool<byte>.Shared.Return(array); 430rented = ArrayPool<byte>.Shared.Rent(maxByteCount); 433ArrayPool<byte>.Shared.Return(rented); 443rented = ArrayPool<byte>.Shared.Rent(MaxArrayPoolRentalSize); 458ArrayPool<byte>.Shared.Return(rented);
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEnumerator.Unix.cs (2)
45_pathBuffer = ArrayPool<char>.Shared.Rent(StandardBufferSize); 231ArrayPool<char>.Shared.Return(pathBuffer);
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (13)
1106buffer = ArrayPool<char>.Shared.Rent(sr.CurrentEncoding.GetMaxCharCount(DefaultBufferSize)); 1124ArrayPool<char>.Shared.Return(buffer); 1221byte[] rentedArray = ArrayPool<byte>.Shared.Rent(512); 1235byte[] tmp = ArrayPool<byte>.Shared.Rent((int)newLength); 1241ArrayPool<byte>.Shared.Return(toReturn); 1256ArrayPool<byte>.Shared.Return(rentedArray); 1477byte[] tmp = ArrayPool<byte>.Shared.Rent((int)newLength); 1483ArrayPool<byte>.Shared.Return(oldRentedArray); 1500ArrayPool<byte>.Shared.Return(rentedArray); 1525Span<byte> bytes = (uint)bytesNeeded <= 1024 ? stackalloc byte[1024] : (rentedBytes = ArrayPool<byte>.Shared.Rent(bytesNeeded)); 1556ArrayPool<byte>.Shared.Return(rentedBytes); 1579byte[] bytes = ArrayPool<byte>.Shared.Rent(preambleSize + encoding.GetMaxByteCount(Math.Min(contents.Length, ChunkSize))); 1608ArrayPool<byte>.Shared.Return(bytes);
src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (12)
64byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 75ArrayPool<byte>.Shared.Return(buffer); 102byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); 113ArrayPool<byte>.Shared.Return(buffer); 315byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 328ArrayPool<byte>.Shared.Return(localBuffer); 737byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 750ArrayPool<byte>.Shared.Return(localBuffer); 782byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 796ArrayPool<byte>.Shared.Return(sharedBuffer); 914byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 922ArrayPool<byte>.Shared.Return(sharedBuffer);
src\libraries\System.Private.CoreLib\src\System\IO\StreamReader.cs (5)
934ArrayPool<char>.Shared.Return(arrayPoolBuffer); 960arrayPoolBuffer = ArrayPool<char>.Shared.Rent(charLen - charPos + 80); 964char[] newBuffer = ArrayPool<char>.Shared.Rent(checked(arrayPoolBufferPos + charLen - charPos)); 966ArrayPool<char>.Shared.Return(arrayPoolBuffer); 977ArrayPool<char>.Shared.Return(arrayPoolBuffer);
src\libraries\System.Private.CoreLib\src\System\IO\TextReader.cs (6)
98char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 112ArrayPool<char>.Shared.Return(array); 148char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 162ArrayPool<char>.Shared.Return(array); 244char[] chars = ArrayPool<char>.Shared.Rent(4096); 255ArrayPool<char>.Shared.Return(chars);
src\libraries\System.Private.CoreLib\src\System\IO\TextWriter.cs (4)
162char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 171ArrayPool<char>.Shared.Return(array); 366char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 375ArrayPool<char>.Shared.Return(array);
src\libraries\System.Private.CoreLib\src\System\Marvin.OrdinalIgnoreCase.cs (2)
86Span<char> scratch = (uint)count <= 64 ? stackalloc char[64] : (borrowedArr = ArrayPool<char>.Shared.Rent(count)); 98ArrayPool<char>.Shared.Return(borrowedArr);
src\libraries\System.Private.CoreLib\src\System\Numerics\INumberBase.cs (15)
319utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount); 330ArrayPool<char>.Shared.Return(utf16TextArray); 345ArrayPool<char>.Shared.Return(utf16TextArray); 453utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount); 464ArrayPool<char>.Shared.Return(utf16TextArray); 480ArrayPool<char>.Shared.Return(utf16TextArray); 499utf16DestinationArray = ArrayPool<char>.Shared.Rent(destinationMaxCharCount); 508ArrayPool<char>.Shared.Return(utf16DestinationArray); 523ArrayPool<char>.Shared.Return(utf16DestinationArray); 555utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount); 566ArrayPool<char>.Shared.Return(utf16TextArray); 581ArrayPool<char>.Shared.Return(utf16TextArray); 602utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount); 613ArrayPool<char>.Shared.Return(utf16TextArray); 629ArrayPool<char>.Shared.Return(utf16TextArray);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs (5)
58_chars = _arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount)); 71_chars = _arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount)); 136ArrayPool<char>.Shared.Return(toReturn); 655char[] newArray = ArrayPool<char>.Shared.Rent(arraySize); 663ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\TypeMapLazyDictionary.cs (2)
104ArrayPool<char>.Shared.Return(_backingArray); 116char[] buffer = ArrayPool<char>.Shared.Rent(needed);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMapState.cs (3)
169bool[] seen = ArrayPool<bool>.Shared.Rent(modulus); 180ArrayPool<bool>.Shared.Return(seen); 188ArrayPool<bool>.Shared.Return(seen);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (2)
1065(borrowedArr = ArrayPool<char>.Shared.Rent(length + 1)); 1091ArrayPool<char>.Shared.Return(borrowedArr);
src\libraries\System.Private.CoreLib\src\System\Text\TranscodingStream.cs (16)
310byte[] rentedBytes = ArrayPool<byte>.Shared.Rent(DefaultReadByteBufferSize); 311char[] rentedChars = ArrayPool<char>.Shared.Rent(_readCharBufferMaxSize); 343ArrayPool<byte>.Shared.Return(rentedBytes); 344ArrayPool<char>.Shared.Return(rentedChars); 389byte[] rentedBytes = ArrayPool<byte>.Shared.Rent(DefaultReadByteBufferSize); 390char[] rentedChars = ArrayPool<char>.Shared.Rent(_readCharBufferMaxSize); 422ArrayPool<byte>.Shared.Return(rentedBytes); 423ArrayPool<char>.Shared.Return(rentedChars); 486char[] scratchChars = ArrayPool<char>.Shared.Rent(rentalLength); 487byte[] scratchBytes = ArrayPool<byte>.Shared.Rent(rentalLength); 531ArrayPool<char>.Shared.Return(scratchChars); 532ArrayPool<byte>.Shared.Return(scratchBytes); 562char[] scratchChars = ArrayPool<char>.Shared.Rent(rentalLength); 563byte[] scratchBytes = ArrayPool<byte>.Shared.Rent(rentalLength); 603ArrayPool<char>.Shared.Return(scratchChars); 604ArrayPool<byte>.Shared.Return(scratchBytes);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (4)
707char[] array = ArrayPool<char>.Shared.Rent(length); 717ArrayPool<char>.Shared.Return(array); 754char[] array = ArrayPool<char>.Shared.Rent(length); 764ArrayPool<char>.Shared.Return(array);
System.Private.CoreLib.Generators (3)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
184ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 235ArrayPool<T>.Shared.Return(toReturn);
System.Private.Uri (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System.Private.Windows.Core (12)
System\BufferScope.cs (7)
10/// Allows renting a buffer from <see cref="ArrayPool{T}"/> with a using statement. Can be used directly as if it 25_array = ArrayPool<T>.Shared.Rent(minimumLength); 56/// the shared <see cref="ArrayPool{T}"/>. 67_array = ArrayPool<T>.Shared.Rent(minimumLength); 89T[] newArray = ArrayPool<T>.Shared.Rent(capacity); 97ArrayPool<T>.Shared.Return(_array); 124ArrayPool<T>.Shared.Return(_array);
System\Text\ValueStringBuilder.cs (5)
29_chars = ArrayPool<char>.Shared.Rent( 43_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 336char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 344ArrayPool<char>.Shared.Return(toReturn); 355ArrayPool<char>.Shared.Return(toReturn);
System.Private.Xml (4)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System.Reflection.Metadata (6)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\Reflection\Internal\Utilities\EncodingHelper.netcoreapp.cs (2)
45byte[] buffer = ArrayPool<byte>.Shared.Rent(prefixedByteCount); 56ArrayPool<byte>.Shared.Return(buffer);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
54[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ArrayPool<>))]
System.Runtime.Numerics (170)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
184ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 235ArrayPool<T>.Shared.Return(toReturn);
System\Number.BigInteger.cs (23)
96buffer = arrayFromPool = ArrayPool<byte>.Shared.Rent(value.Length + 1 + 1); 118ArrayPool<byte>.Shared.Return(arrayFromPool); 352: base1E9FromPool = ArrayPool<uint>.Shared.Rent(base1E9Length)).Slice(0, base1E9Length); 378: resultBufferFromPool = ArrayPool<uint>.Shared.Rent(resultLength)).Slice(0, resultLength); 396ArrayPool<uint>.Shared.Return(base1E9FromPool); 398ArrayPool<uint>.Shared.Return(resultBufferFromPool); 411: powersOf1e9BufferFromPool = ArrayPool<uint>.Shared.Rent(powersOf1e9BufferLength)).Slice(0, powersOf1e9BufferLength); 423: leadingFromPool = ArrayPool<uint>.Shared.Rent(leadingLength)).Slice(0, leadingLength); 432ArrayPool<uint>.Shared.Return(leadingFromPool); 440ArrayPool<uint>.Shared.Return(powersOf1e9BufferFromPool); 470: bufferFromPool = ArrayPool<uint>.Shared.Rent(bufferLength)).Slice(0, bufferLength); 489ArrayPool<uint>.Shared.Return(bufferFromPool); 560bits = arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(bytesWrittenOrNeeded); 618ArrayPool<byte>.Shared.Return(arrayToReturnToPool); 641bytes = arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(bytesWrittenOrNeeded); 657ArrayPool<byte>.Shared.Return(arrayToReturnToPool); 720ArrayPool<byte>.Shared.Return(arrayToReturnToPool); 796(bufferToReturn = ArrayPool<uint>.Shared.Rent(cuMax)); 874(numberBufferToReturn = ArrayPool<byte>.Shared.Rent(valueDigits + 1)); 910ArrayPool<byte>.Shared.Return(numberBufferToReturn); 917ArrayPool<uint>.Shared.Return(bufferToReturn); 1126: powersOfTenFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 1186ArrayPool<uint>.Shared.Return(powersOfTenFromPool);
System\Numerics\BigInteger.cs (74)
779: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 792ArrayPool<uint>.Shared.Return(bitsFromPool); 809: remainderFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 815: quotientFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 823ArrayPool<uint>.Shared.Return(remainderFromPool); 826ArrayPool<uint>.Shared.Return(quotientFromPool); 932: bitsFromPool = ArrayPool<uint>.Shared.Rent(leftBits.Length)).Slice(0, leftBits.Length); 945: bitsFromPool = ArrayPool<uint>.Shared.Rent(leftBits.Length)).Slice(0, leftBits.Length); 952ArrayPool<uint>.Shared.Return(bitsFromPool); 1000: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1025ArrayPool<uint>.Shared.Return(bitsFromPool); 1060: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1071: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1079ArrayPool<uint>.Shared.Return(bitsFromPool); 1688: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1700: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1712: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1724: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1731ArrayPool<uint>.Shared.Return(bitsFromPool); 1766: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1778: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1788: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1800: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 1807ArrayPool<uint>.Shared.Return(bitsFromPool); 2377: leftBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2384: rightBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2391: resultBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2401ArrayPool<uint>.Shared.Return(leftBufferFromPool); 2404ArrayPool<uint>.Shared.Return(rightBufferFromPool); 2409ArrayPool<uint>.Shared.Return(resultBufferFromPool); 2433: leftBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2440: rightBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2447: resultBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2457ArrayPool<uint>.Shared.Return(leftBufferFromPool); 2460ArrayPool<uint>.Shared.Return(rightBufferFromPool); 2465ArrayPool<uint>.Shared.Return(resultBufferFromPool); 2484: leftBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2491: rightBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2498: resultBufferFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2508ArrayPool<uint>.Shared.Return(leftBufferFromPool); 2511ArrayPool<uint>.Shared.Return(rightBufferFromPool); 2516ArrayPool<uint>.Shared.Return(resultBufferFromPool); 2538: xdFromPool = ArrayPool<uint>.Shared.Rent(xl)).Slice(0, xl); 2545: zdFromPool = ArrayPool<uint>.Shared.Rent(zl)).Slice(0, zl); 2573ArrayPool<uint>.Shared.Return(xdFromPool); 2575ArrayPool<uint>.Shared.Return(zdFromPool); 2599: xdFromPool = ArrayPool<uint>.Shared.Rent(xl)).Slice(0, xl); 2627: zdFromPool = ArrayPool<uint>.Shared.Rent(zl)).Slice(0, zl); 2665ArrayPool<uint>.Shared.Return(zdFromPool); 2668ArrayPool<uint>.Shared.Return(xdFromPool); 2741: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2753: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2763: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2775: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2788: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2796ArrayPool<uint>.Shared.Return(bitsFromPool); 2830: quotientFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2841ArrayPool<uint>.Shared.Return(quotientFromPool); 2856: quotientFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2862ArrayPool<uint>.Shared.Return(quotientFromPool); 2906: bitsFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 2912ArrayPool<uint>.Shared.Return(bitsFromPool); 3308: xdFromPool = ArrayPool<uint>.Shared.Rent(xl); 3319: zdFromPool = ArrayPool<uint>.Shared.Rent(zl); 3412ArrayPool<uint>.Shared.Return(xdFromPool); 3414ArrayPool<uint>.Shared.Return(zdFromPool); 3463: xdFromPool = ArrayPool<uint>.Shared.Rent(xl); 3474: zdFromPool = ArrayPool<uint>.Shared.Rent(zl); 3559ArrayPool<uint>.Shared.Return(xdFromPool); 3561ArrayPool<uint>.Shared.Return(zdFromPool); 5324: xdFromPool = ArrayPool<uint>.Shared.Rent(xl)).Slice(0, xl); 5343: zdFromPool = ArrayPool<uint>.Shared.Rent(zl)).Slice(0, zl); 5377ArrayPool<uint>.Shared.Return(zdFromPool); 5380ArrayPool<uint>.Shared.Return(xdFromPool);
System\Numerics\BigIntegerCalculator.DivRem.cs (24)
107: leftCopyFromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 113ArrayPool<uint>.Shared.Return(leftCopyFromPool); 143: quotientFromPool = ArrayPool<uint>.Shared.Rent(quotientLength)).Slice(0, quotientLength); 148ArrayPool<uint>.Shared.Return(quotientFromPool); 180: leftCopyFromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 192: quotientActualFromPool = ArrayPool<uint>.Shared.Rent(quotientLength)).Slice(0, quotientLength); 202ArrayPool<uint>.Shared.Return(quotientActualFromPool); 204ArrayPool<uint>.Shared.Return(leftCopyFromPool); 386: bFromPool = ArrayPool<uint>.Shared.Rent(n)).Slice(0, n); 400: aFromPool = ArrayPool<uint>.Shared.Rent(aLength)).Slice(0, aLength); 440: rFromPool = ArrayPool<uint>.Shared.Rent(n + 1)).Slice(0, n + 1); 445: zFromPool = ArrayPool<uint>.Shared.Rent(2 * n)).Slice(0, 2 * n); 455: qFromPool = ArrayPool<uint>.Shared.Rent(n)).Slice(0, n); 463ArrayPool<uint>.Shared.Return(qFromPool); 479ArrayPool<uint>.Shared.Return(zFromPool); 481ArrayPool<uint>.Shared.Return(bFromPool); 483ArrayPool<uint>.Shared.Return(aFromPool); 515ArrayPool<uint>.Shared.Return(rFromPool); 568: r1FromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 588ArrayPool<uint>.Shared.Return(r1FromPool); 612: r1FromPool = ArrayPool<uint>.Shared.Rent(right.Length + 1)).Slice(0, right.Length + 1); 618ArrayPool<uint>.Shared.Return(r1FromPool); 641: dFromPool = ArrayPool<uint>.Shared.Rent(right.Length)).Slice(0, right.Length); 681ArrayPool<uint>.Shared.Return(dFromPool);
System\Numerics\BigIntegerCalculator.GcdInv.cs (2)
69: rightCopyFromPool = ArrayPool<uint>.Shared.Rent(right.Length)).Slice(0, right.Length); 75ArrayPool<uint>.Shared.Return(rightCopyFromPool);
System\Numerics\BigIntegerCalculator.PowMod.cs (28)
28: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 34: valueCopyFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 43ArrayPool<uint>.Shared.Return(tempFromPool); 45ArrayPool<uint>.Shared.Return(valueCopyFromPool); 221: valueCopyFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 240: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 246ArrayPool<uint>.Shared.Return(valueCopyFromPool); 248ArrayPool<uint>.Shared.Return(tempFromPool); 270: valueCopyFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 289: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 295ArrayPool<uint>.Shared.Return(valueCopyFromPool); 297ArrayPool<uint>.Shared.Return(tempFromPool); 328: rFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 335: muFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 342: q1FromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 348: q2FromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 354ArrayPool<uint>.Shared.Return(rFromPool); 361ArrayPool<uint>.Shared.Return(muFromPool); 363ArrayPool<uint>.Shared.Return(q1FromPool); 365ArrayPool<uint>.Shared.Return(q2FromPool); 388: rFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 395: muFromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 402: q1FromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 408: q2FromPool = ArrayPool<uint>.Shared.Rent(size)).Slice(0, size); 414ArrayPool<uint>.Shared.Return(rFromPool); 421ArrayPool<uint>.Shared.Return(muFromPool); 423ArrayPool<uint>.Shared.Return(q1FromPool); 425ArrayPool<uint>.Shared.Return(q2FromPool);
System\Numerics\BigIntegerCalculator.SquMul.cs (12)
102: foldFromPool = ArrayPool<uint>.Shared.Rent(foldLength)).Slice(0, foldLength); 109: coreFromPool = ArrayPool<uint>.Shared.Rent(coreLength)).Slice(0, coreLength); 119ArrayPool<uint>.Shared.Return(foldFromPool); 127ArrayPool<uint>.Shared.Return(coreFromPool); 227: carryFromPool = ArrayPool<uint>.Shared.Rent(carryLength)).Slice(0, carryLength); 242ArrayPool<uint>.Shared.Return(carryFromPool); 286: leftFoldFromPool = ArrayPool<uint>.Shared.Rent(foldLength)).Slice(0, foldLength); 292: rightFoldFromPool = ArrayPool<uint>.Shared.Rent(foldLength)).Slice(0, foldLength); 305: coreFromPool = ArrayPool<uint>.Shared.Rent(coreLength)).Slice(0, coreLength); 312ArrayPool<uint>.Shared.Return(leftFoldFromPool); 315ArrayPool<uint>.Shared.Return(rightFoldFromPool); 326ArrayPool<uint>.Shared.Return(coreFromPool);
System.Security.Cryptography (75)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (2)
64ArrayPool<byte>.Shared.Return(arrayBuffer); 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs (2)
34byte[] buffer = ArrayPool<byte>.Shared.Rent(1024); 43ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Security\Cryptography\CryptoPool.cs (2)
13internal static byte[] Rent(int minimumLength) => ArrayPool<byte>.Shared.Rent(minimumLength); 37ArrayPool<byte>.Shared.Return(array, clearWholeArray);
src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.Pkcs12.cs (6)
605_certBags = ArrayPool<SafeBagAsn>.Shared.Rent(loaderLimits.MaxCertificates.GetValueOrDefault(10)); 606_keyBags = ArrayPool<SafeBagAsn>.Shared.Rent(loaderLimits.MaxKeys.GetValueOrDefault(10)); 616ArrayPool<SafeBagAsn>.Shared.Return(_certBags, clearArray: true); 621ArrayPool<SafeBagAsn>.Shared.Return(_keyBags, clearArray: true); 760SafeBagAsn[] next = ArrayPool<SafeBagAsn>.Shared.Rent(checked(index + 1)); 762ArrayPool<SafeBagAsn>.Shared.Return(array, clearArray: true);
src\libraries\Common\src\System\Text\UrlBase64Encoding.cs (3)
18char[] base64 = ArrayPool<char>.Shared.Rent(base64Len); 30char[] urlEncoded = ArrayPool<char>.Shared.Rent(urlEncodedLen); 76ArrayPool<char>.Shared.Return(base64);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (2)
30_arrayToReturnToPool = ArrayPool<byte>.Shared.Rent(maxSize); 46ArrayPool<byte>.Shared.Return(toReturn);
System\Security\Cryptography\CryptoStream.cs (14)
345byte[] tempInputBuffer = ArrayPool<byte>.Shared.Rent(numWholeBlocksInBytes); 387byte[] tempOutputBuffer = ArrayPool<byte>.Shared.Rent(numWholeReadBlocks * _outputBlockSize); 397ArrayPool<byte>.Shared.Return(tempOutputBuffer); 418ArrayPool<byte>.Shared.Return(tempInputBuffer); 508byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 521ArrayPool<byte>.Shared.Return(sharedBuffer); 593byte[]? tempOutputBuffer = ArrayPool<byte>.Shared.Rent(checked(numWholeBlocks * _outputBlockSize)); 612ArrayPool<byte>.Shared.Return(tempOutputBuffer); 660byte[]? rentedBuffer = ArrayPool<byte>.Shared.Rent(inputBuffer.Length); 677ArrayPool<byte>.Shared.Return(rentedBuffer); 690byte[]? rentedBuffer = ArrayPool<byte>.Shared.Rent(bufferSize); 708ArrayPool<byte>.Shared.Return(rentedBuffer); 722byte[]? rentedBuffer = ArrayPool<byte>.Shared.Rent(bufferSize); 739ArrayPool<byte>.Shared.Return(rentedBuffer);
System\Security\Cryptography\DSA.cs (2)
898byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 913ArrayPool<byte>.Shared.Return(array);
System\Security\Cryptography\ECDsa.cs (8)
150rented = ArrayPool<byte>.Shared.Rent(maxSignatureSize); 174ArrayPool<byte>.Shared.Return(rented); 432rented = ArrayPool<byte>.Shared.Rent(maxSignatureSize); 456ArrayPool<byte>.Shared.Return(rented); 1009byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 1036ArrayPool<byte>.Shared.Return(array); 1218byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 1233ArrayPool<byte>.Shared.Return(array);
System\Security\Cryptography\HashAlgorithm.cs (6)
97byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 113ArrayPool<byte>.Shared.Return(buffer, clearArray: false); 133byte[] rented = ArrayPool<byte>.Shared.Rent(4096); 149ArrayPool<byte>.Shared.Return(rented, clearArray: false); 254byte[] array = ArrayPool<byte>.Shared.Rent(source.Length); 258ArrayPool<byte>.Shared.Return(array);
System\Security\Cryptography\RandomNumberGenerator.cs (4)
59byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 68ArrayPool<byte>.Shared.Return(array); 82byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 94ArrayPool<byte>.Shared.Return(array);
System\Security\Cryptography\RSA.cs (4)
318byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 327ArrayPool<byte>.Shared.Return(array); 1449byte[] rented = ArrayPool<byte>.Shared.Rent(resultSize); 1465ArrayPool<byte>.Shared.Return(rented);
System\Security\Cryptography\SymmetricAlgorithm.cs (2)
772byte[] decryptRent = ArrayPool<byte>.Shared.Rent(ciphertext.Length); 786ArrayPool<byte>.Shared.Return(decryptRent);
System\Security\Cryptography\X509Certificates\CertificateRequest.Load.cs (2)
53byte[] rented = ArrayPool<byte>.Shared.Rent(fields.DecodedDataLength); 74ArrayPool<byte>.Shared.Return(rented);
System\Security\Cryptography\X509Certificates\CertificateRevocationListBuilder.Load.cs (2)
272byte[] rented = ArrayPool<byte>.Shared.Rent(fields.DecodedDataLength); 286ArrayPool<byte>.Shared.Return(rented);
System\Security\Cryptography\X509Certificates\OpenSslX509ChainProcessor.cs (5)
787ArrayPool<char>.Shared.Return(urlEncoded.Array!); 1355ArrayPool<ErrorCollection>.Shared.Return(toReturn); 1383_errors = ArrayPool<ErrorCollection>.Shared.Rent(size); 1391_errors = ArrayPool<ErrorCollection>.Shared.Rent(errorDepth + 1); 1396ArrayPool<ErrorCollection>.Shared.Return(toReturn);
System\Security\Cryptography\X509Certificates\X509CertificateLoader.Unix.cs (5)
223_certAndKeys = ArrayPool<CertAndKey>.Shared.Rent(bagState.CertCount); 250_keys = ArrayPool<Pkcs12Key?>.Shared.Rent(bagState.KeyCount); 270ArrayPool<RentedSubjectPublicKeyInfo>.Shared.Rent(bagState.KeyCount); 535ArrayPool<CertAndKey>.Shared.Return(certAndKeys, clearArray: true); 552ArrayPool<Pkcs12Key?>.Shared.Return(_keys, clearArray: true);
System.Security.Cryptography.Cose (16)
System\Security\Cryptography\Cose\CoseMessage.cs (4)
435byte[] contentBuffer = ArrayPool<byte>.Shared.Rent(4096); 447ArrayPool<byte>.Shared.Return(contentBuffer, clearArray: true); 471byte[] contentBuffer = ArrayPool<byte>.Shared.Rent(4096); 482ArrayPool<byte>.Shared.Return(contentBuffer, clearArray: true);
System\Security\Cryptography\Cose\CoseMultiSignMessage.cs (4)
778byte[] buffer = ArrayPool<byte>.Shared.Rent(Math.Max(toBeSignedLength, signer.CoseKey.ComputeSignatureSize())); 800ArrayPool<byte>.Shared.Return(buffer, clearArray: true); 854byte[] buffer = ArrayPool<byte>.Shared.Rent(Math.Max(toBeSignedLength, signer.CoseKey.ComputeSignatureSize())); 872ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
System\Security\Cryptography\Cose\CoseSign1Message.cs (4)
795byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferLength); 810ArrayPool<byte>.Shared.Return(buffer, clearArray: true); 948byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferLength); 958ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
System\Security\Cryptography\Cose\CoseSignature.cs (4)
624byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferLength); 640ArrayPool<byte>.Shared.Return(buffer, clearArray: true); 655byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferLength); 671ArrayPool<byte>.Shared.Return(buffer, clearArray: true);
System.Security.Cryptography.Pkcs (2)
src\libraries\Common\src\System\Security\Cryptography\CryptoPool.cs (2)
13internal static byte[] Rent(int minimumLength) => ArrayPool<byte>.Shared.Rent(minimumLength); 37ArrayPool<byte>.Shared.Return(array, clearWholeArray);
System.ServiceModel.NetFramingBase (12)
System\ServiceModel\Channels\Connection.cs (4)
203byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 212ArrayPool<byte>.Shared.Return(sharedBuffer); 242byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 252ArrayPool<byte>.Shared.Return(sharedBuffer);
System\ServiceModel\Channels\FramingChannels.cs (1)
380byte[] faultBuffer = ArrayPool<byte>.Shared.Rent(FaultStringDecoder.FaultSizeQuota);
System\ServiceModel\Channels\SessionConnectionReader.cs (2)
88ArrayPool<byte>.Shared.Return(_buffer); 107_buffer = ArrayPool<byte>.Shared.Rent(_connection.ConnectionBufferSize);
System\ServiceModel\Channels\SingletonConnectionReader.cs (5)
137byte[] buffer = ArrayPool<byte>.Shared.Rent(Connection.ConnectionBufferSize); 159ArrayPool<byte>.Shared.Return(buffer); 174ArrayPool<byte>.Shared.Return(buffer); 538byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 551ArrayPool<byte>.Shared.Return(localBuffer);
System.Text.Encodings.Web (6)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\Text\Encodings\Web\TextEncoder.cs (2)
521char[] rentedArray = ArrayPool<char>.Shared.Rent(Math.Max(value.Length, minBufferBumpEachIteration)); 536ArrayPool<char>.Shared.Return(rentedArray);
System.Text.Json (200)
src\libraries\Common\src\System\Net\ArrayBuffer.cs (4)
45: usePool ? ArrayPool<byte>.Shared.Rent(initialSize) : new byte[initialSize]; 138_bytes = ArrayPool<byte>.Shared.Rent(byteCount); 164ArrayPool<byte>.Shared.Rent(newSize) : 193ArrayPool<byte>.Shared.Return(buffer);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (4)
40: (rentedBuffer = ArrayPool<char>.Shared.Rent(initialBufferLength)); 138ArrayPool<char>.Shared.Return(rentedBuffer); 157char[] newBuffer = ArrayPool<char>.Shared.Rent(newSize); 163ArrayPool<char>.Shared.Return(rentedBuffer);
System\Text\Json\Document\JsonDocument.cs (5)
81ArrayPool<byte>.Shared.Return(extraRentedBytes); 314(otherUtf8TextArray = ArrayPool<byte>.Shared.Rent(length)); 332ArrayPool<byte>.Shared.Return(otherUtf8TextArray); 849byte[] rent = ArrayPool<byte>.Shared.Rent(length); 860ArrayPool<byte>.Shared.Return(rented.Array);
System\Text\Json\Document\JsonDocument.MetadataDb.cs (7)
138byte[] data = ArrayPool<byte>.Shared.Rent(initialSize); 164ArrayPool<byte>.Shared.Return(data); 187ArrayPool<byte>.Shared.Return(returnBuf); 197byte[] newRent = ArrayPool<byte>.Shared.Rent(Length); 210ArrayPool<byte>.Shared.Return(returnBuf); 257_data = ArrayPool<byte>.Shared.Rent(newCapacity); 263ArrayPool<byte>.Shared.Return(toReturn);
System\Text\Json\Document\JsonDocument.Parse.cs (22)
87byte[] utf8Bytes = ArrayPool<byte>.Shared.Rent(length); 102ArrayPool<byte>.Shared.Return(utf8Bytes); 140ArrayPool<byte>.Shared.Return(drained.Array); 167ArrayPool<byte>.Shared.Return(drained.Array); 237ArrayPool<byte>.Shared.Return(drained.Array); 255ArrayPool<byte>.Shared.Return(drained.Array); 286byte[] utf8Bytes = ArrayPool<byte>.Shared.Rent(expectedByteCount); 303ArrayPool<byte>.Shared.Return(utf8Bytes); 312byte[] utf8Bytes = ArrayPool<byte>.Shared.Rent(expectedByteCount); 326ArrayPool<byte>.Shared.Return(utf8Bytes); 647byte[] rented = ArrayPool<byte>.Shared.Rent(length); 669ArrayPool<byte>.Shared.Return(rented); 813rented = ArrayPool<byte>.Shared.Rent(checked((int)expectedLength)); 817rented = ArrayPool<byte>.Shared.Rent(UnseekableStreamInitialRentSize); 848rented = ArrayPool<byte>.Shared.Rent(checked(toReturn.Length * 2)); 851ArrayPool<byte>.Shared.Return(toReturn, clearArray: true); 866ArrayPool<byte>.Shared.Return(rented); 896rented = ArrayPool<byte>.Shared.Rent(checked((int)expectedLength)); 900rented = ArrayPool<byte>.Shared.Rent(UnseekableStreamInitialRentSize); 928rented = ArrayPool<byte>.Shared.Rent(toReturn.Length * 2); 931ArrayPool<byte>.Shared.Return(toReturn, clearArray: true); 948ArrayPool<byte>.Shared.Return(rented);
System\Text\Json\Document\JsonDocument.StackRowStack.cs (4)
23_rentedBuffer = ArrayPool<byte>.Shared.Rent(initialSize); 38ArrayPool<byte>.Shared.Return(toReturn); 66_rentedBuffer = ArrayPool<byte>.Shared.Rent(toReturn.Length * 2); 80ArrayPool<byte>.Shared.Return(toReturn);
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (4)
77byte[] tmpUtf8 = ArrayPool<byte>.Shared.Rent(maxBytes); 98ArrayPool<byte>.Shared.Return(tmpUtf8); 189(rented = ArrayPool<byte>.Shared.Rent(remaining)); 207ArrayPool<byte>.Shared.Return(rented);
System\Text\Json\JsonEncodedText.cs (2)
85(array = ArrayPool<byte>.Shared.Rent(expectedByteCount)); 99ArrayPool<byte>.Shared.Return(array);
System\Text\Json\JsonHelpers.cs (2)
233(rentedBuffer = ArrayPool<char>.Shared.Rent(utf8Key.Length)); 243ArrayPool<char>.Shared.Return(rentedBuffer);
System\Text\Json\JsonHelpers.Escaping.cs (4)
42(valueArray = ArrayPool<byte>.Shared.Rent(length)); 50ArrayPool<byte>.Shared.Return(valueArray); 70(valueArray = ArrayPool<byte>.Shared.Rent(length)); 78ArrayPool<byte>.Shared.Return(valueArray);
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (19)
20(unescapedArray = ArrayPool<byte>.Shared.Rent(utf8Source.Length)); 33ArrayPool<byte>.Shared.Return(unescapedArray); 50(pooledName = ArrayPool<byte>.Shared.Rent(length)); 63ArrayPool<byte>.Shared.Return(pooledName); 77(pooledName = ArrayPool<byte>.Shared.Rent(length)); 88ArrayPool<byte>.Shared.Return(pooledName); 102(unescapedArray = ArrayPool<byte>.Shared.Rent(utf8Source.Length)); 115ArrayPool<byte>.Shared.Return(unescapedArray); 133(unescapedArray = ArrayPool<byte>.Shared.Rent(length)); 137(escapedArray = ArrayPool<byte>.Shared.Rent(length)); 154ArrayPool<byte>.Shared.Return(unescapedArray); 156ArrayPool<byte>.Shared.Return(escapedArray); 175(unescapedArray1 = ArrayPool<byte>.Shared.Rent(utf8Source1.Length)); 179(unescapedArray2 = ArrayPool<byte>.Shared.Rent(utf8Source2.Length)); 194ArrayPool<byte>.Shared.Return(unescapedArray1); 200ArrayPool<byte>.Shared.Return(unescapedArray2); 224(pooledArray = ArrayPool<byte>.Shared.Rent(utf8Unescaped.Length)); 235ArrayPool<byte>.Shared.Return(pooledArray); 247ArrayPool<byte>.Shared.Return(pooledArray);
System\Text\Json\Reader\Utf8JsonReader.cs (2)
544otherUtf8TextArray = ArrayPool<byte>.Shared.Rent(length); 568ArrayPool<byte>.Shared.Return(otherUtf8TextArray);
System\Text\Json\Reader\Utf8JsonReader.TryGet.cs (5)
158(rentedBuffer = ArrayPool<byte>.Shared.Rent(valueLength)); 173(rentedBuffer = ArrayPool<byte>.Shared.Rent(valueLength)); 189ArrayPool<byte>.Shared.Return(rentedBuffer); 210(rentedBuffer = ArrayPool<byte>.Shared.Rent(sequenceLength)); 225ArrayPool<byte>.Shared.Return(rentedBuffer);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.cs (8)
114ArrayPool<FoundProperty>.Shared.Return(toReturn, clearArray: true); 270ArrayPool<FoundPropertyAsync>.Shared.Return(toReturn, clearArray: true); 366ArrayPool<FoundProperty>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length)); 373var newCache = ArrayPool<FoundProperty>.Shared.Rent(argumentState.FoundProperties.Length * 2); 380ArrayPool<FoundProperty>.Shared.Return(toReturn, clearArray: true); 562argumentState.FoundPropertiesAsync = ArrayPool<FoundPropertyAsync>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length)); 568var newCache = ArrayPool<FoundPropertyAsync>.Shared.Rent(argumentState.FoundPropertiesAsync!.Length * 2); 575ArrayPool<FoundPropertyAsync>.Shared.Return(toReturn, clearArray: true);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Large.cs (2)
48ArrayPool<object>.Shared.Return(arguments, clearArray: true); 56object?[] arguments = ArrayPool<object>.Shared.Rent(typeInfo.ParameterCache.Length);
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (2)
246: (rentedBuffer = ArrayPool<char>.Shared.Rent(bufferLength)); 291ArrayPool<char>.Shared.Return(rentedBuffer);
System\Text\Json\Serialization\Converters\Value\HalfConverter.cs (2)
46: (rentedByteBuffer = ArrayPool<byte>.Shared.Rent(bufferLength)); 54ArrayPool<byte>.Shared.Return(rentedByteBuffer);
System\Text\Json\Serialization\Converters\Value\Int128Converter.cs (2)
43: (rentedBuffer = ArrayPool<byte>.Shared.Rent(bufferLength)); 53ArrayPool<byte>.Shared.Return(rentedBuffer);
System\Text\Json\Serialization\Converters\Value\UInt128Converter.cs (2)
43: (rentedBuffer = ArrayPool<byte>.Shared.Rent(bufferLength)); 53ArrayPool<byte>.Shared.Return(rentedBuffer);
System\Text\Json\Serialization\JsonSerializer.Read.String.cs (4)
391json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 407ArrayPool<byte>.Shared.Return(tempArray); 422json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 438ArrayPool<byte>.Shared.Return(tempArray);
System\Text\Json\Serialization\ReadBufferState.cs (4)
46_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(initialBufferSize, JsonConstants.Utf8Bom.Length)); 136byte[] newBuffer = ArrayPool<byte>.Shared.Rent((_buffer.Length < (int.MaxValue / 2)) ? _buffer.Length * 2 : int.MaxValue); 145ArrayPool<byte>.Shared.Return(oldBuffer); 186ArrayPool<byte>.Shared.Return(toReturn);
System\Text\Json\Writer\Utf8JsonWriter.cs (4)
823(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 831ArrayPool<byte>.Shared.Return(propertyArray); 972(propertyArray = ArrayPool<char>.Shared.Rent(length)); 980ArrayPool<char>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Bytes.cs (4)
145(propertyArray = ArrayPool<char>.Shared.Rent(length)); 153ArrayPool<char>.Shared.Return(propertyArray); 168(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 176ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTime.cs (4)
152(propertyArray = ArrayPool<char>.Shared.Rent(length)); 160ArrayPool<char>.Shared.Return(propertyArray); 175(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 183ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTimeOffset.cs (4)
151(propertyArray = ArrayPool<char>.Shared.Rent(length)); 159ArrayPool<char>.Shared.Return(propertyArray); 174(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 182ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Decimal.cs (4)
151(propertyArray = ArrayPool<char>.Shared.Rent(length)); 159ArrayPool<char>.Shared.Return(propertyArray); 174(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 182ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Double.cs (4)
155(propertyArray = ArrayPool<char>.Shared.Rent(length)); 163ArrayPool<char>.Shared.Return(propertyArray); 178(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 186ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Float.cs (4)
155(propertyArray = ArrayPool<char>.Shared.Rent(length)); 163ArrayPool<char>.Shared.Return(propertyArray); 178(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 186ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.FormattedNumber.cs (4)
125(propertyArray = ArrayPool<char>.Shared.Rent(length)); 133ArrayPool<char>.Shared.Return(propertyArray); 148(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 156ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Guid.cs (4)
151(propertyArray = ArrayPool<char>.Shared.Rent(length)); 159ArrayPool<char>.Shared.Return(propertyArray); 174(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 182ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Literal.cs (4)
270(propertyArray = ArrayPool<char>.Shared.Rent(length)); 278ArrayPool<char>.Shared.Return(propertyArray); 293(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 301ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.SignedNumber.cs (4)
224(propertyArray = ArrayPool<char>.Shared.Rent(length)); 232ArrayPool<char>.Shared.Return(propertyArray); 247(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 255ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.String.cs (28)
123propertyArray = ArrayPool<char>.Shared.Rent(length); 139ArrayPool<char>.Shared.Return(propertyArray); 282propertyArray = ArrayPool<byte>.Shared.Rent(length); 298ArrayPool<byte>.Shared.Return(propertyArray); 905(valueArray = ArrayPool<byte>.Shared.Rent(length)); 913ArrayPool<byte>.Shared.Return(valueArray); 928(valueArray = ArrayPool<char>.Shared.Rent(length)); 936ArrayPool<char>.Shared.Return(valueArray); 951(propertyArray = ArrayPool<char>.Shared.Rent(length)); 959ArrayPool<char>.Shared.Return(propertyArray); 974(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 982ArrayPool<byte>.Shared.Return(propertyArray); 1077valueArray = ArrayPool<char>.Shared.Rent(length); 1097propertyArray = ArrayPool<char>.Shared.Rent(length); 1113ArrayPool<char>.Shared.Return(valueArray); 1118ArrayPool<char>.Shared.Return(propertyArray); 1137valueArray = ArrayPool<byte>.Shared.Rent(length); 1157propertyArray = ArrayPool<byte>.Shared.Rent(length); 1173ArrayPool<byte>.Shared.Return(valueArray); 1178ArrayPool<byte>.Shared.Return(propertyArray); 1197valueArray = ArrayPool<byte>.Shared.Rent(length); 1217propertyArray = ArrayPool<char>.Shared.Rent(length); 1233ArrayPool<byte>.Shared.Return(valueArray); 1238ArrayPool<char>.Shared.Return(propertyArray); 1257valueArray = ArrayPool<char>.Shared.Rent(length); 1277propertyArray = ArrayPool<byte>.Shared.Rent(length); 1293ArrayPool<char>.Shared.Return(valueArray); 1298ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.UnsignedNumber.cs (4)
233(propertyArray = ArrayPool<char>.Shared.Rent(length)); 241ArrayPool<char>.Shared.Return(propertyArray); 256(propertyArray = ArrayPool<byte>.Shared.Rent(length)); 264ArrayPool<byte>.Shared.Return(propertyArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Raw.cs (2)
207json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 223ArrayPool<byte>.Shared.Return(tempArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.String.cs (4)
194(valueArray = ArrayPool<char>.Shared.Rent(length)); 202ArrayPool<char>.Shared.Return(valueArray); 341(valueArray = ArrayPool<byte>.Shared.Rent(length)); 349ArrayPool<byte>.Shared.Return(valueArray);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.StringSegment.cs (4)
144(valueArray = ArrayPool<char>.Shared.Rent(length)); 160ArrayPool<char>.Shared.Return(valueArray); 310(valueArray = ArrayPool<byte>.Shared.Rent(length)); 326ArrayPool<byte>.Shared.Return(valueArray);
System.Text.Json.SourceGeneration (7)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
184ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 235ArrayPool<T>.Shared.Return(toReturn);
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (4)
40: (rentedBuffer = ArrayPool<char>.Shared.Rent(initialBufferLength)); 138ArrayPool<char>.Shared.Return(rentedBuffer); 157char[] newBuffer = ArrayPool<char>.Shared.Rent(newSize); 163ArrayPool<char>.Shared.Return(rentedBuffer);
System.Text.RegularExpressions (13)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
184ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 235ArrayPool<T>.Shared.Return(toReturn);
System\Text\RegularExpressions\Symbolic\MintermClassifier.cs (2)
53object[] arrayPoolArray = ArrayPool<object>.Shared.Rent(minterms.Length); 77ArrayPool<object>.Shared.Return(arrayPoolArray);
System\Text\StructListBuilder.cs (4)
14/// <summary>The array backing the builder, obtained from <see cref="ArrayPool{T}.Shared"/>.</summary> 51ArrayPool<T>.Shared.Return(_array, clearArray: RuntimeHelpers.IsReferenceOrContainsReferences<T>()); 66T[] newArray = _array = ArrayPool<T>.Shared.Rent(newSize); 68ArrayPool<T>.Shared.Return(array, clearArray: RuntimeHelpers.IsReferenceOrContainsReferences<T>());
System.Text.RegularExpressions.Generator (7)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
184ArrayPool<T>.Shared.Return(toReturn); 213T[] array = ArrayPool<T>.Shared.Rent(nextCapacity); 235ArrayPool<T>.Shared.Return(toReturn);
System.Web.HttpUtility (8)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (4)
28_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity); 294char[] poolArray = ArrayPool<char>.Shared.Rent(newCapacity); 302ArrayPool<char>.Shared.Return(toReturn); 313ArrayPool<char>.Shared.Return(toReturn);
System\Web\Util\HttpEncoder.cs (4)
569byte[] bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(toEncode.Length)); 571char[] chars = ArrayPool<char>.Shared.Rent(utf8Length * 3); 587ArrayPool<byte>.Shared.Return(bytes); 592ArrayPool<char>.Shared.Return(chars);
System.Windows.Forms.UI.IntegrationTests (2)
Infra\ScreenRecordService.cs (2)
26private static readonly ArrayPool<byte> s_pool = ArrayPool<byte>.Shared;
Test.Utilities (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
Text.Analyzers (6)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (4)
115byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 129ArrayPool<byte>.Shared.Return(buffer); 160byte[] buffer = ArrayPool<byte>.Shared.Rent(4096); 178ArrayPool<byte>.Shared.Return(buffer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (2)
92: System.Buffers.ArrayPool<byte>.Shared.Rent(decodedLength); 112System.Buffers.ArrayPool<byte>.Shared.Return(rentedArray);
TlsFeaturesObserve (1)
Program.cs (1)
40var bytes = ArrayPool<byte>.Shared.Rent(bytesReturned);