Class MemoryAllocator
- Namespace
- SixLabors.ImageSharp.Memory
- Assembly
- SixLabors.ImageSharp.dll
Memory managers are used to allocate memory for image processing operations.
public abstract class MemoryAllocator
- Inheritance
-
MemoryAllocator
- Derived
- Inherited Members
- Extension Methods
Constructors
MemoryAllocator()
protected MemoryAllocator()
Properties
Default
Gets the default platform-specific global MemoryAllocator instance that serves as the default value for MemoryAllocator.
This is a get-only property, you should set Default's MemoryAllocator to change the default allocator used by Image and it's operations.public static MemoryAllocator Default { get; }
Property Value
Methods
Allocate<T>(int, AllocationOptions)
Allocates an IMemoryOwner<T>, holding a Memory<T> of length length.
public abstract IMemoryOwner<T> Allocate<T>(int length, AllocationOptions options = AllocationOptions.None) where T : struct
Parameters
lengthintSize of the buffer to allocate.
optionsAllocationOptionsThe allocation options.
Returns
- IMemoryOwner<T>
A buffer of values of type
T.
Type Parameters
TType of the data stored in the buffer.
Exceptions
- ArgumentOutOfRangeException
When length is zero or negative.
- InvalidMemoryOperationException
When length is over the capacity of the allocator.
Create()
Creates a default instance of a MemoryAllocator optimized for the executing platform.
public static MemoryAllocator Create()
Returns
Create(MemoryAllocatorOptions)
Creates the default MemoryAllocator using the provided options.
public static MemoryAllocator Create(MemoryAllocatorOptions options)
Parameters
optionsMemoryAllocatorOptions
Returns
GetBufferCapacityInBytes()
Gets the length of the largest contiguous buffer that can be handled by this allocator instance in bytes.
protected abstract int GetBufferCapacityInBytes()
Returns
- int
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.
public virtual void ReleaseRetainedResources()