Class SimpleGcMemoryAllocator
Implements MemoryAllocator by newing up managed arrays on every allocation request.
Inherited Members
Namespace: SixLabors.ImageSharp.Memory
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class SimpleGcMemoryAllocator : MemoryAllocator
Methods
| Improve this Doc View SourceAllocate<T>(Int32, AllocationOptions)
Allocates an IMemoryOwner<T>, holding a Memory<T> of length length
.
Declaration
public override 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. |
Overrides
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 override 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. |
Overrides
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 override int GetBufferCapacityInBytes()
Returns
Type | Description |
---|---|
Int32 | The length of the largest contiguous buffer that can be handled by this allocator instance. |