Search Unity

Unity Resources RAM Usage

Discussion in 'Editor & General Support' started by Ceylan12, Aug 15, 2020.

  1. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Hello,
    It's multiplayer game that using Photon. I have 15 car and 15 prefab in resources folder. I'm spawning single car but memory profiler show all car textures uses RAM. How can I prevent that? Thank you.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    Hi,
    You can avoid that by not using the Resources folder, which makes detailed and controlled memory usage quite hard to achieve. It will be build into a single AssetBundle and then fully load the index into Memory. Assets loaded from it may remain in memory longer as needed in the scene and you have less control over when they get loaded in, as e.g. loading an object that references them will load them into memory. Instead, you can get more control by placing these assets in separate asset bundles. Consider using the Addressables System. The manual has further resources on this.
     
    Last edited: Oct 17, 2021
    IronNick and ritesh_khokhani like this.
  3. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank you, If I use asset bundle, It will load into memory only required prefabs and referenced textures etc... right ? Can I use the Asset bundle without getting data from the internet? My main problem is memory usage :)
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    Yes, you can use AssetBundles without downloading them from a server, you'll just build them into the game and ship them all together.

    And yes, depending on how you structure your AssetBundles, you can get fine grained control about which resources get loaded. That link I posted above leads to some further links and tutorials that should help getting you started :)
     
    IronNick and Valentin-Emerge like this.
  5. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank you for reply.
    Have a good day.
     
    MartinTilo likes this.