Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Texture2Ds not getting released due to ManagedStaticReferences

Discussion in 'iOS and tvOS' started by davekalina, Jun 11, 2015.

  1. davekalina

    davekalina

    Joined:
    Apr 2, 2013
    Posts:
    39
    The Unity Profiler is showing that there are Texture2Ds in my Scene Memory which are not getting released, even though almost nothing is pointing to them.

    There is only 1 reference, which is "ManagedStaticReferences"

    I think I get the basic concept here -- something static (like a Singleton) that was destroyed was holding onto a reference to this Texture2D. Since it was nuked, there is no way to see who was holding onto the Texture2D.

    But making it even more impossible is that the Texture2D reports no name in the profiler. There are multiple 2MB textures, and I have NO idea what they are.

    Anybody have any ideas on how I might track this down? There are 3 of these dangling 2MB guys hanging around, and on the iPad 2 and such, 6MB can make a big difference...
     

    Attached Files:

  2. davekalina

    davekalina

    Joined:
    Apr 2, 2013
    Posts:
    39
    Anyone? Bueller?
     
  3. davekalina

    davekalina

    Joined:
    Apr 2, 2013
    Posts:
    39
    I know you're all dying with anticipation to know how this was resolved, so...

    We had a static prefab instance called UIMaster, which pointed at another persistent prefab called InGameUIMaster which it intended on spawning only in some levels and destroying when we didn't need it. Apparently just pointing at this other prefab resulted in phantom memory getting allocated, for reasons I fail to understand fully.

    The solution was to instead spawn the InGameUIMaster by using Resources.Load to grab the prefab and the instantiate it.

    I wish somebody had told me about Resources.Load two years ago.
     
    futurlab_xbox likes this.
  4. futurlab_xbox

    futurlab_xbox

    Joined:
    Nov 5, 2018
    Posts:
    22

    2020 and this exact same situation still occurs, even when using the SpriteAtlasManager API...