Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Control how much memory shaders use

Limit the size of chunks of shader data, and how many decompressed chunks Unity keeps in memory.
Read time 1 minuteLast updated a month ago

In your built application, Unity stores several 'chunks' of compressed shader variant data. Each chunk contains multiple shader variants. When Unity loads a scene at runtime, it loads all the scene's chunks into CPU memory and decompresses them.
To reduce memory usage on platforms that have limited memory, you can limit the size of chunks and how many decompressed chunks Unity keeps in memory.
To do this, in Player settings, select Other Settings > Shader Variant Loading and adjust the following settings:
  • Use Default chunk size (MB) to set the maximum size of compressed chunks Unity stores in your built application.
  • Use Default chunk count to limit how many decompressed chunks Unity keeps in memory. The default is
    0
    , which means there's no limit.
You can use Override to override the values for each platform individually. See PlayerSettings.SetShaderChunkCountForPlatform for more information.
You can also use Shader.maximumChunksOverride to override Default chunk count at runtime.