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 MemoryAllocatorProperties
| Improve this Doc View SourceDefault
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.
Declaration
public static MemoryAllocator Default { get; }Property Value
| Type | Description | 
|---|---|
| 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 : structParameters
| 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. | 
Create()
Creates a default instance of a MemoryAllocator optimized for the executing platform.
Declaration
public static MemoryAllocator Create()Returns
| Type | Description | 
|---|---|
| MemoryAllocator | The MemoryAllocator. | 
Create(MemoryAllocatorOptions)
Creates the default MemoryAllocator using the provided options.
Declaration
public static MemoryAllocator Create(MemoryAllocatorOptions options)Parameters
| Type | Name | Description | 
|---|---|---|
| MemoryAllocatorOptions | options | 
Returns
| Type | Description | 
|---|---|
| MemoryAllocator | The MemoryAllocator. | 
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()