MemoryManager<T> 类

定义

用于替换 Memory<T> 实现的抽象基类。An abstract base class that is used to replace the implementation of Memory<T>.

generic <typename T>
public ref class MemoryManager abstract : System::Buffers::IMemoryOwner<T>, System::Buffers::IPinnable
public abstract class MemoryManager<T> : System.Buffers.IMemoryOwner<T>, System.Buffers.IPinnable
type MemoryManager<'T> = class
    interface IMemoryOwner<'T>
    interface IDisposable
    interface IPinnable
Public MustInherit Class MemoryManager(Of T)
Implements IMemoryOwner(Of T), IPinnable

类型参数

T

此内存管理器管理的内存缓冲区中的项的类型。The type of items in the memory buffer managed by this memory manager.

继承
MemoryManager<T>
实现

注解

MemoryManager<T> 类用于扩展 Memory<T> 能够表示的类型的知识。The MemoryManager<T> class is used to extend the knowledge of types that Memory<T> is able to represent. 例如,可以从 MemoryManager<T> 派生,以允许 SafeHandle实现 Memory<T>For example, you can derive from MemoryManager<T> to allow Memory<T> to be backed by a SafeHandle.

备注

MemoryManager<T> 类适用于高级方案。The MemoryManager<T> class is intended for advanced scenarios. 大多数开发人员不需要使用它。Most developers do not need to use it.

构造函数

MemoryManager<T>()

初始化 MemoryManager<T> 类的新实例。Initializes a new instance of the MemoryManager<T> class.

属性

Memory

获取由此 MemoryManager<T> 处理的内存块。Gets the memory block handled by this MemoryManager<T>.

方法

CreateMemory(Int32)

返回一个内存缓冲区,它由当前内存管理器管理的内存中指定数量的元素构成。Returns a memory buffer consisting of a specified number of elements from the memory managed by the current memory manager.

CreateMemory(Int32, Int32)

返回一个内存缓冲区,它由当前内存管理器管理的内存中指定数量(初始偏移量为指定的偏移量)的元素构成。Returns a memory buffer consisting of a specified number of elements starting at a specified offset from the memory managed by the current memory manager.

Dispose(Boolean)

释放由当前内存管理器使用的所有资源。Releases all resources used by the current memory manager.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetSpan()

返回包装基础内存缓冲区的内存范围。Returns a memory span that wraps the underlying memory buffer.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Pin(Int32)

返回已固定且可以获取其地址的内存的句柄。Returns a handle to the memory that has been pinned and whose address can be taken.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
TryGetArray(ArraySegment<T>)

返回数组段。Returns an array segment.

Unpin()

取消固定已固定的内存,使垃圾回收器能够自由移动它。Unpins pinned memory so that the garbage collector is free to move it.

显式接口实现

IDisposable.Dispose()

释放由内存管理器使用的所有资源。Releases all resources used by the memory manager.

适用于