Class MemoryAllocator
Memory managers are used to allocate memory for image processing operations.
Inherited Members
Namespace: SixLabors.ImageSharp.Memory
Assembly: SixLabors.ImageSharp.dll
Syntax
public abstract class MemoryAllocator
Methods
| Improve this Doc View SourceAllocate<T>(Int32, AllocationOptions)
Allocates an IMemoryOwner<T>, holding a Memory<T> of length length
.
Declaration
public abstract IMemoryOwner<T> Allocate<T>(int length, AllocationOptions options = AllocationOptions.None)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | Size of the buffer to allocate. |
AllocationOptions | options | The allocation options. |
Returns
Type | Description |
---|---|
IMemoryOwner<T> | A buffer of values of type |
Type Parameters
Name | Description |
---|---|
T | Type of the data stored in the buffer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | When length is zero or negative. |
InvalidMemoryOperationException | When length is over the capacity of the allocator. |
AllocateManagedByteBuffer(Int32, AllocationOptions)
Allocates an IManagedByteBuffer.
Declaration
public abstract IManagedByteBuffer AllocateManagedByteBuffer(int length, AllocationOptions options = AllocationOptions.None)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The requested buffer length. |
AllocationOptions | options | The allocation options. |
Returns
Type | Description |
---|---|
IManagedByteBuffer | The IManagedByteBuffer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | When length is zero or negative. |
InvalidMemoryOperationException | When length is over the capacity of the allocator. |
GetBufferCapacityInBytes()
Gets the length of the largest contiguous buffer that can be handled by this allocator instance in bytes.
Declaration
protected abstract int GetBufferCapacityInBytes()
Returns
Type | Description |
---|---|
Int32 | The length of the largest contiguous buffer that can be handled by this allocator instance. |
ReleaseRetainedResources()
Releases all retained resources not being in use. Eg: by resetting array pools and letting GC to free the arrays.
Declaration
public virtual void ReleaseRetainedResources()