The Collections package has different allocators that you can use to manage memory allocations. The different allocators organize and track their memory in different ways. These are the allocators available:
The Entities package has its own set of custom prebuilt allocators:
For more information, see the Entities documentation on Custom prebuilt allocators.
The different allocators have the following different features:
Allocator type | Custom Allocator | Need to create before use | Lifetime | Automatically freed allocations | Can pass to jobs | Min Allocation Alignment (bytes) |
---|---|---|---|---|---|---|
Allocator.Temp | No | No | A frame or a job | Yes | No | 64 |
Allocator.TempJob | No | No | Within 4 frames of creation | No | Yes | 16 |
Allocator.Persistent | No | No | Indefinite | No | Yes | 16 |
Rewindable allocator | Yes | Yes | Indefinite | No | Yes | 64 |
The following performance tests compare Temp, TempJob, Persistent and rewindable allocators. Because the world update allocator, entity command buffer allocator, and system group allocator are rewindable allocators, their performance is reflected in the rewindable allocator test results. The allocators are tested in single thread cases and in multithread cases by scheduling allocations in jobs across all the cores.
For results, refer to the Performance comparison of allocators documentation.