docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Allocators overview

    Entities and 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:

    • Allocator.Temp: A fast allocator for short-lived allocations, which is created on every thread.
    • Allocator.TempJob: A short-lived allocator, which must be deallocated within 4 frames of their creation.
    • Allocator.Persistent: The slowest allocator for indefinite lifetime allocations.
    • Rewindable allocator: A custom allocator that is fast and thread safe, and can rewind and free all your allocations at one point.
    • World update allocator: A double rewindable allocator that a world owns, which is fast and thread safe.
    • Entity command buffer allocator: A rewindable allocator that an entity command buffer system owns and uses to create entity command buffers.
    • System group allocator: An optional double rewindable allocator that a component system group creates when setting its rate manager. It's for allocations in a system of fixed or variable rate system group that ticks at different rate from the world update.

    Allocator feature comparison

    The different allocators have the following different features:

    Allocator type Custom Allocator Need to create before use Lifetime Automatically freed allocations Can pass allocations to jobs
    Allocator.Temp No No A frame or a job Yes No
    Allocator.TempJob No No Within 4 frames of creation No Yes
    Allocator.Persistent No No Indefinite No Yes
    Rewindable allocator Yes Yes Indefinite No Yes
    World update allocator Yes - a double rewindable allocator No Every 2 frames Yes Yes
    Entity command buffer allocator Yes - a rewindable allocator No Same as the entity command buffer Yes Yes
    System group allocator Yes - a double rewindable allocator Yes 2 fixed rate system group updates Yes Yes

    Additional resources

    • Custom prebuilt allocators overview
    • Rewindable allocators
    • Allocator benchmarks
    In This Article
    • Allocator feature comparison
    • Additional resources
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)