Documentation

Unity Engine


Unity Engine


Native memory allocators reference

Reference for native memory allocator settings
Read time 4 minutesLast updated 3 days ago

You can control how native memory is allocated through using command line arguments, or using the settings in the Unity Editor (Edit > Project Settings > Memory Settings). For information on how to customize native memory allocators, refer to Customizing native memory allocators.

Project Settings > Memory Settings, showing a selection of Player memory settings

The following table contains information about each allocator setting, plus their command line arguments, and their default values:

Main Allocators

These allocators are the ones that Unity uses for most allocations.

Main Allocator

The primary allocator Unity uses for most allocations. It has the following settings:

Setting

Description

Command line argument

Default value

Main Thread Block SizeBlock size of dedicated main thread allocator. This property is automatically disabled when you use mimalloc.
memorysetup-main-allocator-block-size
16777216
bytes
Shared Thread Block SizeBlock size of shared thread allocator. This property is automatically disabled when you use mimalloc.
memorysetup-thread-allocator-block-size
16777216
bytes
Mimalloc enabledUses mimalloc instead of the main thread and shared thread.NoneEnabled

Gfx Allocator

The allocator Unity uses for CPU allocations related to the Gfx system. It has the following settings:

Setting

Description

Command line argument

Default value

Main Thread Block SizeBlock size of the dedicated main thread Gfx allocator.
memorysetup-gfx-main-allocator-block-size
16777216
bytes
Shared Thread Block SizeBlock size of the shared thread Gfx allocator.
memorysetup-gfx-thread-allocator-block-size
16777216
bytes

Other Allocators

Allocations used for type trees and the file cache. It has the following settings:

Setting

Description

Command line argument

Default value

File Cache Block SizeThe file cache has its own allocator to avoid fragmentation. This is its block size.
memorysetup-cache-allocator-block-size
4194304
bytes
Type Tree Block SizeThe type trees have their own allocator to avoid fragmentation due to many small allocations. This is its block size.
memorysetup-typetree-allocator-block-size
2097152
bytes

Shared Bucket Allocator

The bucket allocator shared between the main allocators. It has the following settings:

Setting

Description

Command line argument

Default value

Bucket Allocator GranularityStep size for buckets in the shared allocator.
memorysetup-bucket-allocator-granularity
16
bytes
Bucket Allocator BucketCountNumber of bucket sizes.
memorysetup-bucket-allocator-bucket-count
8
Bucket Allocator Block SizeSize of memory blocks used for buckets.
memorysetup-bucket-allocator-block-size
Editor:
8388608
bytes
Player:
4194304
bytes
Bucket Allocator Block CountMaximum number of blocks to be allocated.
memorysetup-bucket-allocator-block-count
Editor:
8

Player:
1

Fast Per Thread Temporary Allocators

The Thread Local Storage (TLS) allocator that handles very short-lived allocations.

Allocator

Description

Command line argument

Default value (in bytes)

Main Thread Block SizeThe initial size for the main thread stack.
memorysetup-temp-allocator-size-main
Editor:
16777216

Player:
4194304
Job Worker Block SizeSize of each job worker in the Unity job system.
memorysetup-temp-allocator-size-job-worker
E262144
Background Job Worker Block SizeSize for each background worker.
memorysetup-temp-allocator-size-background-worker
32768
Preload Block SizeThe preload manager stack size.
memorysetup-temp-allocator-size-preload-manager
Editor:
33554432

Player:
262144
Audio Worker Block SizeEach audio worker thread's stack size.
memorysetup-temp-allocator-size-audio-worker
65536
Cloud Worker Block SizeCloud worker threads stack size.
memorysetup-temp-allocator-size-cloud-worker
32768
Gfx Thread BlocksizeThe main render threads stack size.
memorysetup-temp-allocator-size-gfx
262144
GI Baking BlocksizeEach GI worker thread's stack size.
memorysetup-temp-allocator-size-gi-baking-worker
262144
NavMesh Worker Block SizeNav mesh worker threads stack size.
memorysetup-temp-allocator-size-nav-mesh-worker
65536

Fast Thread Shared Temporary Allocators

Fast linear allocator for short lived allocations shared between threads.

Allocator

Description

Command line argument

Default value (in bytes)

Job Allocator Block SizeThe round robin linear thread allocator Unity mainly uses for the job worker threads.
memorysetup-job-temp-allocator-block-size
2097152
Background Job Allocator Block SizeThe linear allocator for the background workers, such as asynchronous asset loading, that allows longer lived allocations. Unity rounds the block size up to the nearest power of two. This allocator only grows, and can reserve up to 512 times the rounded block size. For more information, refer to Reduce the memory footprint of the background job allocator.
memorysetup-job-temp-allocator-block-size-background
1048576
Job Allocator Block Size on low memory platformsDevices with less than 2 GB of physical memory use this size for both the job workers and the background jobs. Unity checks the device's physical memory when the application starts. Devices with 2 GB of memory or more use Job Allocator Block Size and Background Job Allocator Block Size, regardless of platform.
memorysetup-job-temp-allocator-reduction-small-platforms
262144

Profiler Allocators

Allocators that Unity uses exclusively for the Profiler so that they don't interfere with the application's allocation patterns. They have the following settings:

Setting

Description

Command line argument

Default value

Profiler Block SizeThe block size for the main part of the Profiler.
memorysetup-profiler-allocator-block-size
16777216
Editor Profiler Block SizeBlock size for the Editor part of the Profiler. This isn't present in players.
memorysetup-profiler-editor-allocator-block-size
1048576
bytes

Shared Profiler Bucket Allocator

Shared bucket allocator for the Profiler and Editor Profiler allocators. Not present on low memory platforms. It has the following settings:

Setting

Description

Command line argument

Default value

Bucket Allocator GranularityStep size for buckets in the shared allocator.
memorysetup-profiler-bucket-allocator-granularity
16
bytes
Bucket Allocator BucketCountNumber of bucket sizes. For example, if the value is 4, the sizes are 16 bytes, 32 bytes, 48 bytes, and 64 bytes.
memorysetup-profiler-bucket-allocator-bucket-count
8
Bucket Allocator Block SizeSize of memory blocks used for buckets.
memorysetup-profiler-bucket-allocator-block-size
Editor:
33554432
bytes
Player:
4194304
bytes
Bucket Allocator Block CountMaximum number of blocks to be allocated.
memorysetup-profiler-bucket-allocator-block-count
Editor:
8

Player:
1

Additional resources