Search Unity

When does the bundle be unload ?

Discussion in 'Addressables' started by wangyucheng1992, Jul 1, 2019.

  1. wangyucheng1992

    wangyucheng1992

    Joined:
    Feb 19, 2019
    Posts:
    59
    Hello friends !
    I have been studying ABS recently, It is a good system, The system automatically manages the loading and unloading of bundles, But When does it start unload the bundles(which reference num=0)? I have read the code but fail,so I have a few thoughts:

    1). Every time we delete an object (ReleaseInstance()), in a bundle(A) all assets` referenceNum was 0,So the system has determined that A can be unloaded; I have try to checkout it,first I InstantiateAsync(a) it tasks 53.02ms, then ReleaseInstance(A) and wait for few times late InstanceAsync(a) it tasks 5.31ms , So I believe the bundle was not unload immediately when the bundle`s referenceNum is 0;

    2). The ABS have set an fixed time intervals T,and check once each T,some bundle (referenceNum = 0) will be unload.

    The above is just my guess, seek the truth !
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    If you set a breakpoint in AssetBundleProvider Release (you may have to bring the package into your project to do this) you can see that it releases the bundles as soon as the ref count is 0.

    If it's going that quickly on reload, it could be some optimization of the OS itself. Or perhaps you turned on some pooling option I forgot we had! Either way, you should be able to set break points in our code to see when things are actually unloaded. (that breakpoint mentioned above eventually leads to m_AssetBundle.Unload(true);)