Search code examples
unity-game-engine

unity: Addressable Scene seems heavier than regular scene


I am developing an app with unity that takes a lot of memory on startup when I include all the scenes, so I started looking at Addressables, since my game is divided into many maps I decided to split my addressables bundles by scene. Although thankfully my game no longer crashes on startup due to out of memory exception, I now have the out of memory exception when loading any scenes, even though these scenes were not crashing individually when loaded normally, so I just moved my problem a little it seems.

I still don't quite understand what happens behind the curtain with addressables it seems, could someone help me out? How could I reduce the memory usage when loading an addressable scene? Or Is there something better than addressable I could use to lower memory usage on startup?


Solution

  • Your problem is within your assets rather than the Addressables system. Addressables is just an option for managing resources, not the magic pill to fix all memory issues.

    First, you need to identify your current issues. The built-in Unity3d profiler can help a lot with that. Then, you will see your problem.

    What can I assume based on the information you provided:

    • the number of assets loaded simultaneously causes the issue.
    • perhaps you are not releasing your assets. That will prevent assets from being unloaded. Check this part of the documentation
    • perhaps, you are loading your scenes additively, that does not unload the previous scene from memory
    • perhaps, this is the old Unity issue with the order of loading new assets and unloading old ones. Only after you have all assets from the second scene loaded, the assets from the first scene begin to unload. In that case, you have a short time when both scenes' assets are loaded simultaneously. If this is the case, loading using the empty scene can help (I mean load an empty scene to ensure all the old assets are unloaded and only then load the target scene).