DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.7.3" />

 MemoryAllocator

public static class MemoryAllocator
Represents interop layer between .NET memory pools and MemoryAllocator<T>.
public static MemoryOwner<T> Allocate<T>(int length, bool exactSize)

Rents a block of memory from Shared pool.

public static MemoryAllocator<T> CreateArrayAllocator<T>()

Returns array allocator.

public static MemoryOwner<T> Invoke<T>(this MemoryAllocator<T> allocator, int length, bool exactSize)

Allocates memory.

public static MemoryAllocator<T> ToAllocator<T>(this ArrayPool<T> pool)

Converts array pool to the memory allocator.

public static MemoryAllocator<T> ToAllocator<T>(this MemoryPool<T> pool)

Converts memory pool to the memory allocator.

public static MemoryAllocator<T> ToAllocator<T>(this Func<int, IMemoryOwner<T>> provider)

Converts memory provider to the memory allocator.