IMemoryOwner<T> Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Identifies the owner of a block of memory who is responsible for disposing of the underlying memory appropriately.
generic <typename T>
public interface class IMemoryOwner : IDisposable
public interface IMemoryOwner<T> : IDisposable
type IMemoryOwner<'T> = interface
interface IDisposable
Public Interface IMemoryOwner(Of T)
Implements 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) |