- Home /
Do the scenes in Build Settings affect RAM memory on Android?
I'm having memory issues in my Android application. The setup is like this:
1) I have a Scene0 (which is very light, it contains just the camera, global application logic and managers) and it is the one that starts with the app
2) The second scene to run is Scene1, which is loaded asynchronously by a manager without deallocating Scene0 (additive mode). It is quite large and heavy.
3) The third scene, Scene2, is listed in the Build Settings "Scenes in Build" but it is NOT loaded until the user presses a button. Scene2 is totally different from Scene1 (different assets are referenced) and it is heavy aswell.
When i test the app from desktop, everything seems ok. On Android, the app crashes while it is trying to load Scene1. Logcat says it is an "out of memory" problem. Here's the strange thing: if I remove Scene2 from the Build Settings "Scenes in Build" list, Scene1 is loaded fine.
I tried to analyze the app and the Profiler (linked to the android execution) clearly shows that the Unity internal PreloadManager is asynchronously loading 1GB of assets (when Scene2 is listed in the build scenes) before Scene1 is loaded! Those assets cannot be those part of Scene1 because the app reaches the max available memory and crashes...
What does it mean? Are scenes affecting RAM memory even when they are not loaded? I'm clearly missing something. I'm 100% sure that Scene2 is not loaded by script.
I am using Unity 2019.1.2f1, deploying on Oculus Go
Hey @LorenzoValente, did you find a solution? I am experiencing the exact same issue with Unity 2019.4.23f1on an Android device and using Oculus integration within the projectt, but it is still not clear to me what might be wrong
I have exactly the same problem using unity 2020.3LTS. Did you find the solution?
Answer by JasperCiti · May 15, 2019 at 03:51 PM
Are your assets loaded from AssetBundles?
You could specify BuildAssetBundleOptions.ChunkBasedCompression or BuildAssetBundleOptions.UncompressedAssetBundle which should only load the assets in memory that are required, but from what I understood from https://docs.unity3d.com/Manual/AssetBundles-Building.html, the default behavior seems to load all assets into RAM.
Thanks you for the answer JasperCiti, no, I'm not using any AssetBundle