Show / Hide Table of Contents

Class UnmanagedMemoryPool<T>

Represents pool of unmanaged memory.

Inheritance
Object
MemoryPool<T>
UnmanagedMemoryPool<T>
Implements
IDisposable
Inherited Members
MemoryPool<T>.Dispose()
MemoryPool<T>.Shared
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext.Buffers
Assembly: DotNext.Unsafe.dll
Syntax
public sealed class UnmanagedMemoryPool<T> : MemoryPool<T>, IDisposable where T : struct
Type Parameters
Name Description
T

The type of the items in the memory pool.

Constructors

| Improve this Doc View Source

UnmanagedMemoryPool(Int32, Int32, Boolean)

Initializes a new pool of unmanaged memory.

Declaration
public UnmanagedMemoryPool(int maxBufferSize, int defaultBufferSize = 32, bool trackAllocations = false)
Parameters
Type Name Description
Int32 maxBufferSize

The maximum allowed number of elements that can be allocated by the pool.

Int32 defaultBufferSize

The default number of elements that can be allocated by the pool.

Boolean trackAllocations

true to release allocated unmanaged memory when Dispose(Boolean) is called; otherwise, false.

Properties

| Improve this Doc View Source

MaxBufferSize

Gets the maximum elements that can be allocated by this pool.

Declaration
public override int MaxBufferSize { get; }
Property Value
Type Description
Int32
Overrides
System.Buffers.MemoryPool<T>.MaxBufferSize

Methods

| Improve this Doc View Source

Allocate(Int32, Boolean)

Allocates unmanaged memory and returns an object that controls its lifetime.

Declaration
public static IUnmanagedMemoryOwner<T> Allocate(int length, bool zeroMem = true)
Parameters
Type Name Description
Int32 length

The number of elements to be allocated in unmanaged memory.

Boolean zeroMem

true to set all bits in the memory to zero; otherwise, false.

Returns
Type Description
IUnmanagedMemoryOwner<T>

The object representing allocated unmanaged memory.

| Improve this Doc View Source

Dispose(Boolean)

Frees the unmanaged resources used by the memory pool and optionally releases the managed resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Overrides
System.Buffers.MemoryPool<T>.Dispose(System.Boolean)
| Improve this Doc View Source

GetAllocator(Boolean)

Gets allocator of unmanaged memory.

Declaration
public static MemoryAllocator<T> GetAllocator(bool zeroMem)
Parameters
Type Name Description
Boolean zeroMem

true to set all bits in the memory to zero; otherwise, false.

Returns
Type Description
MemoryAllocator<T>

The unmanaged memory allocator.

| Improve this Doc View Source

Rent(Int32)

Returns unmanaged memory block capable of holding at least length elements of T.

Declaration
public override IMemoryOwner<T> Rent(int length = -1)
Parameters
Type Name Description
Int32 length

The length of the continuous block of memory.

Returns
Type Description
IMemoryOwner<T>

The allocated block of unmanaged memory.

Overrides
System.Buffers.MemoryPool<T>.Rent(System.Int32)
Exceptions
Type Condition
ArgumentOutOfRangeException

length is greater than MaxBufferSize.

Implements

System.IDisposable

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>)
ObjectExtensions.As<T>(T)
MemoryAllocator.ToAllocator<T>(MemoryPool<T>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX