Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by CerebralFrost · Jan 12, 2019 at 05:11 AM · androidmemoryshaderlabprofiling

What causes ShaderLab memory to grow?

I have an android app with an .apk size of 451MB. This app is frequently running out of memory on the device I'm using to test (the particular device has about 1.8 GB of usable memory for the app before low memory killer kicks in).


When looking in the profiler, Unity is reporting ShaderLab occupying .6GB (!)


Does anyone know what causes ShaderLab to occupy so much memory?


Better yet, does anyone know how to pre-compile all shaders so that ShaderLab doesn't run at runtime at all (I don't have any scripts creating shaders at runtime, so I would think that I shouldn't need to compile any shaders at runtime)?


So far I've tried (using Unity 2017.4.1f1 and 2018.2.19f1):


  1. Stripping and using shader variant collections as detailed here: https://docs.unity3d.com/Manual/OptimizingShaderLoadTime.html


  2. bundling all materials / shaders into a separate asset bundle and putting it into the streaming assets folder, and loading that asset bundle at runtime on demand.


  3. Using a custom version of the standard shader and removing unused multi_compile* keywords (for example, on mobile we aren't using realtime shadows, so I've removed all of the realtime shadow passes and multi_compile_fwdadd_fullshadows from the standard shader and switched all of our materials to using it). I've also removed the deferred passes from the custom standard shader.


The result of #3 above resulted in fewer shader variants being compiled, however "ShaderLab" still occupies between .6 and .7 GB in the profiler:

alt text


If it helps any, the project is using 313 materials and 33 shaders

shaderlabmemusage.png (15.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by CerebralFrost · Jan 21, 2019 at 08:14 PM

I'm still not 100% sure how to control ShaderLab's memory usage, but doing the things I mentioned above, in addition to the step below, helped reduce the memory usage in my project by about 200MB. The thing that I was missing was that not all of the shaders were being included in the asset bundle - specifically the built in shaders. If the shaders aren't in the asset bundle (even if the materials referencing them are), they will be duplicate-included in subsequent asset bundles that reference them. so to add to the steps above:


0) Remove usage of any and all 'hidden' built-in shaders - replace with 'custom' copies of the shaders from Unity's repo, and make sure those shaders are included in the asset bundle from step 2. The only shader that I found that can't be switched out this way is the error shader.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image starform-joshrosen · Mar 19, 2019 at 05:34 AM 0
Share

In the original screenshot, I see 0.69 GB (690 $$anonymous$$B). You mentioned reducing by 200$$anonymous$$B, so does that mean you are still seeing 500$$anonymous$$B of memory usage from shaders on mobile?

avatar image CerebralFrost starform-joshrosen · Mar 19, 2019 at 10:18 PM 0
Share

Yeah, that's about right, just did a profile to double check, and it's sitting at 485.1 $$anonymous$$B for ShaderLab

avatar image
0

Answer by matheus_inmotionvr · Feb 27, 2020 at 11:24 AM

I was running into the same problem and a simple Unity upgrade (from 2019.2.15 to 2019.2.21) fixed it. Before, ShaderLab's memory consumption would hit 250Mb, not it doesn't go over 30Mb.

This forum thread might be relevant because it discusses the same issue.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

288 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Memory Profiler does not detect my mobile 0 Answers

Does using extra scenes use more memory? 1 Answer

My game randomly crashes on some devices why ? and how do i fix ? 1 Answer

Memory Issues while App Launching,Memory Spike right before Splash Screen(Cold Start?) 0 Answers

What is the best way to deep profile memory usage ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges