I'm trying to learn how to use Addressables in Unity to improve memory usage, but there's something I don't understand.
I use Graphy tool to analyze memory usage.
When I load a GameObject, both Reserved and Allocated memory increase. When I call Release, only the Allocated memory decreases — which is expected and I understand that.
At the start of the game, before loading the GameObject.
After releasing the GameObject.
What I don't understand is that with every load operation, Reserved memory keeps increasing, even though Allocated memory stays the same after Release. This means that during each load, Reserved memory grows and never stops increasing. Why does this happen? I'm loading the same GameObject every time, so shouldn't the memory have already been expanded the first time? There shouldn't be a need to expand it again, especially since I'm sure the GameObject is being fully released.
After many load and release operations of the GameObject, the Reserved memory reached 318 MB.
After releasing the GameObject, the Reserved memory size was 310 MB, with relatively stable Allocated memory size since the start of the game after the release operation.
The code:
using UnityEngine;
using UnityEngine.AddressableAssets;
public class AddressablesManager : MonoBehaviour
{
[SerializeField] private AssetReferenceGameObject assetReferenceGameObject;
private GameObject spawnedGameObject;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.D))
{
Load();
}
if (Input.GetKeyDown(KeyCode.R))
{
Release();
}
}
void Load()
{
assetReferenceGameObject.InstantiateAsync().Completed += (asyncOperation) => spawnedGameObject = asyncOperation.Result;
}
void Release()
{
assetReferenceGameObject.ReleaseInstance(spawnedGameObject);
spawnedGameObject = null;
}
}


