DotNext by Roman Sakno

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

 MemoryOwner<T>

Represents unified representation of the memory rented using various types of memory pools.
public bool IsEmpty { get; }

Determines whether this memory is empty.

public ref T this[int index] { get; }

Gets managed pointer to the item in the rented memory.

public int Length { get; }

Gets length of the rented memory, in bytes.

public Memory<T> Memory { get; }

Gets the memory belonging to this owner.

public MemoryOwner(ArrayPool<T> pool, int length)

Rents the array from the pool.

public MemoryOwner(MemoryPool<T> pool, int length = -1)

Rents the memory from the pool.

public MemoryOwner(Func<int, IMemoryOwner<T>> provider, int length)

Retns the memory.

public MemoryOwner(Func<IMemoryOwner<T>> provider)

Rents the memory.

public MemoryOwner(T[] array, int length)

Wraps the array as if it was rented.

public MemoryOwner(T[] array)

Wraps the array as if it was rented.

public void Dispose()

Releases rented memory.