When a scene transition is performed using LoadSceneModeSingle, the Scenes count in Addressable Assets is not decremented and continues to increase.
For example, calling the following Scenes alternately causes a memory leak.
Calling Resources.UnloadUnusedAssets(); makes no change.
public class EmptyScene : MonoBehaviour
{
IEnumerator LoadSceneSingle()
{
var handle = Addressables.LoadSceneAsync( "empty2" , UnityEngine.SceneManagement.LoadSceneMode.Single );
yield return handle;
}
}
public class EmptyScene2 : MonoBehaviour
{
IEnumerator LoadSceneSingle()
{
var handle = Addressables.LoadSceneAsync( "empty" , UnityEngine.SceneManagement.LoadSceneMode.Single );
yield return handle;
}
}
The following is the result of repeating the scene transition 100 times with the above code.
The Profiler shows that Scene Count in Addressables Assets is 102, and the counter is not decreasing.
Hi @ysalpha! I agree that this does look like a bug and can’t see anything similar in our bugs database. Are you able to file a bug with a sample project that demonstrates the issue? (Those two clips of code above aren’t enough to be able to reproduce this locally for me…)
Although this is probably a bug, as mentioned above, I wonder if you are explicitly releasing the handle? If not, you could try doing that after the scene loads and seeing if it solves the issue. I don’t think it will cause the scene to unload, although I could be mistaken.
If I use LoadSceneModeAdditive to explicitly release the handle, this issue does not occur.
I have not tried using LoadSceneModeSingle to explicitly release the handle.