Search Unity

Track Loaded / Unloaded Bundles

Discussion in 'Addressables' started by cg-adam, Feb 7, 2020.

  1. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    How can we check which bundles have been loaded into memory and when they are unloaded? I am testing loading a prefab through addressables, and then testing unloading it through addressables. How can I verify that a bundle has been unloaded and the memory for that is free'd up?

    On another note when using the event viewer I am not getting any ref counts within the viewer for when loading and unloading, which is hard to track the bundles correctly.

    It would be great to get a guide on how to do this properly. We are concerned of a memory leak right now because bundles are not being unloaded properly.

    Adam
     
  2. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    Any help here is appreciated.
     
  3. CameronND

    CameronND

    Joined:
    Oct 2, 2018
    Posts:
    89
    I also would like to know about this. Currently I have been using the memory profiler but it seems a bit clunky to have to take a snapshot and then analyze that when the addressables system should already have knowledge about whats loaded and unloaded
     
  4. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    154
    @cg-adam the event viewer tracks memory usage with the loaded / unloaded bundles. What other functionality are you looking for?
     
  5. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    Well, for one it does not seem to work (as per my original post). In all modes I have tried in the editor it is very hard to tell what is loaded and unloaded (plus there are multiple threads on here relating to handles not being disposed properly).

    Second, I really want something at runtime. They clearly have a system which checks to see if a bundle can be unloaded (as this is what they use to unload the bundles) but we do not have access to it.
     
  6. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Sounds like you could use
    Code (CSharp):
    1. AssetBundle.GetAllLoadedAssetBundles
    if you wanted to track that. Just be aware if you start managing unloading bundles yourself that it may have unintended side effects with the Addressables system.
     
  7. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    Our issue is that we have a project with multiple games inside it, these games are stored in bundles which the addressables system loads when required. However when going back into the Lobby and launching a new game, the previous bundles are not unloaded, eventually causing memory issues and crashes. We are struggling at times to find out WHY a bundle is not being unloaded, what it keeping it loaded / in memory, and how to force it to unload. It would be great if there was a tool to track an individual bundle, its assets, and what is causing it to be kept alive in memory.
     
  8. CameronND

    CameronND

    Joined:
    Oct 2, 2018
    Posts:
    89

    +1