I am making an attempt to discover ways to use Addressables
in Unity to enhance reminiscence utilization, however there’s one thing I do not perceive.
I take advantage of the Graphy
instrument to investigate 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.
Firstly 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, though 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 have to develop it once more, particularly since I am certain the GameObject is being totally launched.
After many load and launch operations of the GameObject, the Reserved reminiscence reached 318 MB.
After releasing the GameObject, the Reserved reminiscence dimension was 310 MB, with comparatively steady Allotted reminiscence dimension for the reason that 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 known as 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.Outcome;
}
void Launch()
{
assetReferenceGameObject.ReleaseInstance(spawnedGameObject);
spawnedGameObject = null;
}
}