docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Allocator benchmarks

    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's fast and thread safe, and can rewind and free all your allocations at one point.

    The Entities package has its own set of custom prebuilt allocators:

    • 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.

    For more information, see the Entities documentation on Custom prebuilt allocators.

    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 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

    Performance test results

    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.

    In This Article
    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)