Les på engelsk Rediger

Del via


IMemoryOwner<T> Interface

Definition

Identifies the owner of a block of memory who is responsible for disposing of the underlying memory appropriately.

public interface IMemoryOwner<T> : IDisposable

Type Parameters

T

The type of elements to store in memory.

Derived
Implements

Remarks

The IMemoryOwner<T> interface is used to define the owner responsible for the lifetime management of a Memory<T> buffer. An instance of the IMemoryOwner<T> interface is returned by the MemoryPool<T>.Rent method.

While a buffer can have multiple consumers, it can only have a single owner at any given time. The owner can:

  • Create the buffer either directly or by calling a factory method.

  • Transfer ownership to another consumer. In this case, the previous owner should no longer use the buffer.

  • Destroy the buffer when it is no longer in use.

Because the IMemoryOwner<T> object implements the IDisposable interface, you should call its Dispose method only after the memory buffer is no longer needed and you have destroyed it. You should not dispose of the IMemoryOwner<T> object while a reference to its memory is available. This means that the type in which IMemoryOwner<T> is declared should not have a Finalize method.

Properties

Memory

Gets the memory belonging to this owner.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from IDisposable)

Applies to

Produkt Versjoner
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1