Struct SlabAllocator

Public

A tiny slab allocator.

Allocates spans of type T in power-of-two sized blocks.

Note

This allocator has no support for merging adjacent freed blocks. Therefore it is best suited for similarly sized allocations which are relatively small.

Can be used in burst jobs.

This is faster than allocating NativeArrays using the Temp allocator, and significantly faster than allocating them using the Persistent allocator.

Inner Types

Public Methods

Allocate (values)

Allocates an array big enough to fit the given values and copies them to the new allocation.

Public
Allocate (values)

Allocates an array big enough to fit the given values and copies them to the new allocation.

Public
Allocate (nElements)

Allocates an array of type T with length nElements.

Public
CheckDisposed ()
Public
Clear ()

Frees all existing allocations.

Public
CopyTo (other)
Public
Dispose ()

Frees all unmanaged memory associated with this container.

Public
Free (allocatedIndex)

Frees a single allocation.

Public
GetList (allocatedIndex)
Public
GetSpan (allocatedIndex)

Get the span representing the given allocation.

Public
Realloc (allocatedIndex, nElements)
Public
SlabAllocator (initialCapacityBytes, allocator)
Public

Public Variables

ByteSize
Public
IsCreated
Public
IsDebugAllocator
Public
data
Public

Public Static Variables

AllocatedBit
Public Static
InvalidAllocation

Allocation which is always invalid.

Public Static
LengthMask
Public Static
MaxAllocationSize
Public Static
MaxAllocationSizeIndex
Public Static
UsedBit
Public Static
ZeroLengthArray

Allocation representing a zero-length array.

Public Static

Private/Protected Members

ElementsToSizeIndex (nElements)
Internal Static
SizeIndexToElements (sizeIndex)
Internal Static