For around a year now I’ve been trying to figure out why untracked memory is so high (fixing the memory that I can track was quite straight forward), the last time after almost a month trying to fix it I just gave up, nothing I tried worked and no suggested fix did anything to help, now with the Switch release upon us I cannot ignore it anymore, but after a whole week fighting it I’m out of options, this is what happens:
The game loads, the memory is around 500mb in the main menu (good)
We load an game scene, the memory goes up to 700mb or so (good)
Now if we go back to the main menu, or any other scene the memory goes to 1.4gb (not good)
the increase is mostly around untracked memory that goes up to around 0.7gb or so, which means I cannot see what is causing it, but what concerns me is that even if I load a completely empty scene multiple times with absolutely nothing on it, the untracked memory is still 0.7GB, in that completely empty scene I added one script with the following code:
using System;
using UnityEngine;
public class ClearMemoryEmptyScene : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Resources.UnloadUnusedAssets();
GC.Collect();
}
}
the scene is completely empty, but that resolves nothing, all I want at this point is to tell Unity to please, clear anything it may have, start again, be one with the void and load the next scene fresh.
- I tried to clear all Addressables.
- Made sure that any static in the previous scene is null ondestroy and ondisable
- Destroyed every gameobject of the scene
- Used Resources.UnloadUnusedAssets(); on the new scenes
- Used GC.Collect(); in the new scenes
- Emptied the Resource folder
This is driving me to insanity and it is the last thing I need to deal with for what would be a smooth console release, but Unity won’t budge, anyone has any suggestion?
screenshots of the exact same scene being reloaded from itself