I am attempting to study to make use of Addressables
Within the unit to enhance using reminiscence, however there’s something that I don’t perceive.
I exploit the Graphy
Software to investigate using reminiscence.
When loading a gameobject, the reserved and assigned reminiscence will increase. Once I name liberation, solely the assigned reminiscence decreases, what is anticipated and I perceive it.
Initially of the sport, earlier than loading the gameobject.
After launching the gameobject.
What I don’t perceive is that with every load operation, the reserved reminiscence continues to extend, even though the assigned reminiscence stays the identical after the discharge. Because of this throughout every load, the reserved reminiscence grows and by no means stops rising. Why does this occur? I’m loading the identical gameobject each time, so should not reminiscence increase the primary time? There needs to be no have to increase it once more, particularly as a result of I’m certain that Gameobject is totally launched.
After many loading and launch operations of the gameobject, the reserved reminiscence reached 318 MB.
After releasing the gameobject, the reserved reminiscence dimension was 310 MB, with a comparatively secure assigned reminiscence dimension from the beginning of the sport after the launch operation.
The code:
utilizing UnityEngine;
utilizing UnityEngine.AddressableAssets;
public class AddressablesManager : MonoBehaviour
{
(SerializeField) non-public AssetReferenceGameObject assetReferenceGameObject;
non-public GameObject spawnedGameObject;
// Replace 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;
}
}