Struct HeapAllocator
Represents a generic best-fit heap allocation algorithm that operates on abstract integer indices.
Namespace: Unity.Rendering
Assembly: solution.dll
Syntax
public struct HeapAllocator
Remarks
You can use this to suballocate memory, GPU buffer contents, and DX12 descriptors. This supports alignments, resizing, and coalescing of freed blocks.
Constructors
| Name | Description |
|---|---|
| HeapAllocator(ulong, uint) | Creates a new HeapAllocator with the given initial size and alignment. |
Properties
| Name | Description |
|---|---|
| Empty | Indicates whether the allocator is empty. This is true if the allocator is empty and false otherwise. |
| FreeSpace | The amount of available free space in the allocator. |
| Full | Indicates whether the allocator is full. This is true if the allocator is full and false otherwise. |
| IsCreated | Indicates whether the allocator has been created and not yet allocated. |
| Size | The size of the heap that the allocator manages. |
| UsedSpace | The amount of used space in the allocator. |
Methods
| Name | Description |
|---|---|
| Allocate(ulong, uint) | Attempt to allocate a block from the heap with at least the given size and alignment. |
| Clear() | Clears the allocator. |
| Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
| Release(HeapBlock) | Releases a given block of memory and marks it as free. |
| Resize(ulong) | Attempts to grow or shrink the allocator. Growing always succeeds, but shrinking might fail if the end of the heap is allocated. |