Addressables LoadAssetAsync loading very slow when 0 references

Hi,

We are managing our cars in our game as Addressables, which are local to the game (not remote) by unloading one before we load the next, and the problem we find is when we have 0 references, the next LoadAssetAsync is very slow. About 10 seconds on most platforms.

We have found that if we hold a reference open to 1 Dummy addressable with the following:

our cars Unload and Load in under 1 second each, which is what we expect.

AddressablesManager.Instantiate is:

Is there a setting in our AddressableAssets that we should set to have them somehow stay “warm” or some other explanation of why this happens?

Thanks.

You could call Addressables.ResourceManager.Acquire(handle) to increase the reference count of the specified operation, so it will never unload, unless you call it’s counter-part Release too.

We do it to get DontDestroyOnLoad working too, where all objects from a global manager scene should be kept in memory always:

var appEntryOp = Addressables.LoadSceneAsync(addressableKey, LoadSceneMode.Single);
// We need to increase the reference count for the scene, otherwise Addressables unloads
// all dependencies from memory as soon as we switch the scene, because Addressables
// does not support GameObject.DontDestroyOnLoad
// https://discussions.unity.com/t/821105/5
Addressables.ResourceManager.Acquire(appEntryOp);

Thanks Peter77. That’s a nice alternate way.
Have you ever found out why it’s so slow to load the first item? Is the system letting go of a low-level file or something when there are no references left?

That’s how I understand Addressables operates.

How I assume the system works would be:
If the reference-count for a particular AssetBundle hits 0, the bundle gets unloaded and its memory released. If you then request an item from this bundle again, it must open the bundle, load the data from disk, build its internal file-table, perhaps decompress it and then load the item. If the bundle is open already, it just needs to load the item, thus being faster.

Keeping a bundle open, that contains a lot of different assets, can become an issue as far as I understand it. The reason for it being, that you can’t unload individual assets from memory that are located in the same bundle. You can only unload the bundle to free up memory. I believe that’s why somewhere in the Addressables documentation they mention to avoid having gigantic bundles with lots of assets in it.

EDIT: Here is the text from the documentation I was talking about:

7580701--939613--upload_2021-10-18_7-49-52.png
https://docs.unity3d.com/Packages/com.unity.addressables@1.19/manual/AddressablesFAQ.html

Here is the documentation “understanding when memory is cleared”:
https://docs.unity3d.com/Packages/com.unity.addressables@1.19/manual/MemoryManagement.html#when-is-memory-cleared

That actually makes a whole lot of sense. Thanks Peter. Time to experiment with different Packing strategies :slight_smile:

1 Like