Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RewindableAllocator

An allocator that is fast like a linear allocator, is threadsafe, and automatically invalidates all allocations made from it, when "rewound" by the user.
Read time 2 minutesLast updated 7 days ago

Definition

[BurstCompile]public struct RewindableAllocator : AllocatorManager.IAllocator, IDisposable

Properties

Property

Description

BlocksAllocatedRetrieves the number of memory blocks that the allocator has requested from the system.
EnableBlockFreeProperty to get and set enable block free flag, a flag indicating whether the allocator should enable individual block to be freed.
FunctionAll allocators must implement this property, in order to be installed in the custom allocator table.
HandleRetrieve the AllocatorHandle associated with this allocator. The handle is used as an index into a global table, for times when a reference to the allocator object isn't available.
InitialSizeInBytesRetrieves the size of the initial memory block, as requested in the Initialize function.
IsAutoDisposeCheck whether this allocator will automatically dispose allocations.
IsCustomAllocatorCheck whether this AllocatorHandle is a custom allocator.
ToAllocatorRetrieve the Allocator associated with this allocator.

Methods

Method

Description

AllocateNativeArrayAllocate a NativeArray of type T from memory that is guaranteed to remain valid until the end of the next Update of this World. There is no need to Dispose the NativeArray so allocated. It is not possible to free the memory by Disposing it - it is automatically freed after the end of the next Update for this World.
AllocateNativeListAllocate a NativeList of type T from memory that is guaranteed to remain valid until the end of the next Update of this World. There is no need to Dispose the NativeList so allocated. It is not possible to free the memory by Disposing it - it is automatically freed after the end of the next Update for this World. The NativeList must be initialized with its maximum capacity; if it were to dynamically resize, up to 1/2 of the total final capacity would be wasted, because the memory can't be dynamically freed.
DisposeDispose the allocator. This must be called to free the memory blocks that were allocated from the system.
InitializeInitializes the allocator. Must be called before first use.
RewindRewind the allocator; invalidate all allocations made from it, and potentially also free memory blocks it has allocated from the system.
TryTry to allocate, free, or reallocate a block of memory. This is an internal function, and is not generally called by the user.