Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Untracked memory is being impossible to fix and is delaying console release

Discussion in 'Editor & General Support' started by dr4, Apr 11, 2024.

  1. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    108
    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:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3.  
    4. public class ClearMemoryEmptyScene : MonoBehaviour
    5. {
    6.     // Start is called before the first frame update
    7.     void Start()
    8.     {
    9.         Resources.UnloadUnusedAssets();
    10.         GC.Collect();
    11.     }
    12. }
    13.  
    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

    upload_2024-4-11_23-6-37.png

    upload_2024-4-11_23-7-10.png