Search Unity

Question Addressables Memory Management

Discussion in 'Addressables' started by FlyVC, Jun 4, 2020.

  1. FlyVC

    FlyVC

    Joined:
    Jan 5, 2020
    Posts:
    30
    Hello, Unity community :)

    I watched many tutorials and read the documentation but is still do not fully understand how Memory is managed.

    When I watch the addressables profiler everything works as expected, however, the Memory reading in the regular profiler does not reflect the actions in the code.

    When I load an asset(a prefab with a bit material on it) with LoadAssetAsync, the texture memory does not increase, it only increases when I actually instantiate the prefab. Is this expected?

    after Releasing the instance and releasing the handle to the asset, the Texture memory does not go back to normal. I have no clue why not?

    Further interesting is that the Texture memory only starts"empty" when I restart the editor, after it gets increased once by instantiating, it stays at that level each time I start the play mode.

    Code (CSharp):
    1.    
    2.     public AssetReference referenceA;
    3.     private AsyncOperationHandle _assetHandle;
    4.     public GameObject instanceA;
    5.  
    6.     public void LoadAdressable()
    7.     {
    8.         _assetHandle = Addressables.LoadAssetAsync<GameObject>(referenceA);
    9.     }
    10.  
    11.     public void ReleaseAdressable()
    12.     {
    13.         Addressables.Release(_assetHandle);
    14.     }
    15.  
    16.     public void InstantiateA()
    17.     {
    18.         instanceA = referenceA.InstantiateAsync(Vector3.zero, Quaternion.identity).Result;
    19.     }
    20.  
    21.     public void DestroyA()
    22.     {
    23.         Addressables.ReleaseInstance(instanceA.gameObject);
    24.     }
    25.  

    this tutorial does exactly what I want to achieve, however when I load his project, it simply does not work(memory never goes back down)