Note: The information on allocators in this section applies to native memory only and is not applicable to the managed heap, which is covered in the Managed memory section. This section assumes you have a general understanding of native memory management and allocators.
An application uses memory allocators to balance performance and available memory space. If an application has a lot of spare memory, it can favour faster, memory-heavy allocators when it loads scenesA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary and frames. However, if the application has limited memory, it needs to use that memory efficiently, even if that means using slower allocators. To help you get the best performance for different projects, you can customize Unity’s allocators to fit the size and requirements of each application.
Unity has five allocator types. Each type has a different algorithm for fitting allocations into blocks of memory, and is therefore useful for different allocations. The important difference between allocations is usually persistence, or allocation lifespan, which determines where an allocation should go. For example, a long-lived (persistent) allocation goes to the heap and bucket allocators, while short-lived allocations go to the threadsafe linear and TLS allocators.
This table lists the algorithm and uses of each allocator type:
Allocator type | Algorithm | Used for |
---|---|---|
Dynamic heap | Two Level Segregated Fit (TLSF) | • Main allocator • Gfx allocator • Typetree allocator • File cache allocator • Profiler allocator • Editor Profiler allocator (on Editor only) |
Bucket | Fixed size lock-free allocator | As a shared allocator for small allocations for: • Main allocator • Gfx allocator • Typetree allocator • File cache allocator |
Dual thread | Redirects allocations based on size and thread ID | • Main allocator • Gfx allocator • Typetree allocator • File cache allocator |
Thread Local Storage (TLS) stack | LIFO stack | Temporary allocations |
Threadsafe linear | Round robin FIFO | Buffers for passing data to jobs |
Note: The examples in this documentation use the memory usage reports that are written to the log when you close the Player or Editor if you have used the
-log-memory-performance-stats
command line argument. To find your log files, follow the instructions on the log files page.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.