I am attempting to learn to use Addressables
in Unity to enhance reminiscence utilization, however there’s one thing I do not perceive.
I exploit the Graphy
device to research reminiscence utilization.
Once I load a GameObject, each Reserved and Allotted reminiscence enhance. Once I name Launch, solely the Allotted reminiscence decreases — which is anticipated and I perceive that.
Initially of the sport, earlier than loading the GameObject.
After releasing the GameObject.
What I do not perceive is that with each load operation, Reserved reminiscence retains growing, although Allotted reminiscence stays the identical after Launch. Which means throughout every load, Reserved reminiscence grows and by no means stops growing. Why does this occur? I am loading the identical GameObject each time, so should not the reminiscence have already been expanded the primary time? There should not be a must develop it once more, particularly since I am certain the GameObject is being absolutely launched.
After many load and launch operations of the GameObject, the Reserved reminiscence reached 318 MB.
After releasing the GameObject, the Reserved reminiscence measurement was 310 MB, with comparatively steady Allotted reminiscence measurement because the begin of the sport after the discharge operation.
The code:
utilizing UnityEngine;
utilizing UnityEngine.AddressableAssets;
public class AddressablesManager : MonoBehaviour
{
[SerializeField] personal AssetReferenceGameObject assetReferenceGameObject;
personal GameObject spawnedGameObject;
// Replace is named as soon as per body
void Replace()
{
if (Enter.GetKeyDown(KeyCode.D))
{
Load();
}
if (Enter.GetKeyDown(KeyCode.R))
{
Launch();
}
}
void Load()
{
assetReferenceGameObject.InstantiateAsync().Accomplished += (asyncOperation) => spawnedGameObject = asyncOperation.Consequence;
}
void Launch()
{
assetReferenceGameObject.ReleaseInstance(spawnedGameObject);
spawnedGameObject = null;
}
}