Search Unity

Android Memory Profiler - ShaderLab takes 70% of game's memory?

Discussion in 'Editor & General Support' started by Axel-F, Sep 26, 2014.

  1. Axel-F

    Axel-F

    Joined:
    Mar 20, 2009
    Posts:
    224
    Hi,

    in an Android project of mine I've run into some serious memory problems. My scene consumes ~110MB Ram wirth all scripts and gameobjects deactivated. So the scene does practically nothing. However, Unity's Android memory profiles states in the deailed view in the "other" section that ShaderLab consumes 70MB of memory. The other memory is spent into texture's and meshes.
    What the hell does this means? Is it shader cache? But as all gameobjects are deactivated nothing is rendered in that scene. What can I do to reduce this value??

    Thanks in advance!

    -Axel
     
  2. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    Last edited: Dec 29, 2015
  3. Art-Leaping

    Art-Leaping

    Joined:
    Apr 2, 2015
    Posts:
    22
    Why is there no answer to this thread?
     
  4. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Seriously.
     
  5. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    I've forgot this thread. In my project, ShaderLab section goes up for 2 reasons.
    1. Set 'Standard' shader in Graphic's 'always included shaders' settings. this will lead all the shader variants in Standard shader precompiled, and the memory taken would be really HUGE. Other ways to include 'Standard' shader in your project could result the same.
    2. Loading too much assetbundle where it contains shaders. we use assetbundle to manage assets. so every assetbundle include it's own shader asset even they may actually the same. and when they are loaded, lots of duplicated shader would be loaded too, and it will make ShaderLab large too. Create assetbundle with dependencies will help.

    you can check the 'Shader' section in MemoryProfiler, commonly the more asset in that, the more memory ShaderLab takes. We use about 5 to 8 custom shaders with a lot of Keyword to cover all our needs, and it takes ShaderLab less than 5MB
     
    sylon likes this.
  6. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    61
    We are also experiencing problems with ShaderLab memory in our latest project. I have written a post about it here
    https://forum.unity.com/threads/shaderlab-memory-doubled-in-size.526511/

    I've done numerous tests to try to figure out what makes ShaderLab grow, all tests indicates that the number and size of the shaders makes it grow. BUT, then as you can see in my test in the post i've made between version 1.0.12 and 1.0.14, 1.0.14 uses less shader memory but has a bigger ShaderLab.

    It would be nice if someone from Unity could explain what is going on and what approach to have to make it as small as possible.
     
  7. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    sorry for necro, did anyone figure this out?
     
  8. matheus_inmotionvr

    matheus_inmotionvr

    Joined:
    Oct 3, 2018
    Posts:
    63
    No news on this? I'm still facing this issue on Unity 2019.2.15,
     
  9. matheus_inmotionvr

    matheus_inmotionvr

    Joined:
    Oct 3, 2018
    Posts:
    63
    The excessive amount of memory used by ShaderLab was gone after I updated the project to Unity 2019.2.21.

    This forum thread might be relevant.