Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity UI Sprite Atlas Texture Leak

Discussion in 'UGUI & TextMesh Pro' started by npruehs, May 29, 2017.

  1. npruehs

    npruehs

    Joined:
    Jul 20, 2012
    Posts:
    67
    Hey everybody,

    we are experiencing some really strange issues with our current game, developed with Unity 5.4.5f1.

    Symptom: The game crashes after loading a particular scene 80+ times.

    After some research, we were confident this had to be related to some memory leak. Further investigation revealed that we seem to be leaking Unity UI SpriteAtlasTextures (see first screenshot). Every time the scene is loaded, another instance of the same atlas is loaded into memory.

    Clearly, this is something I wouldn't expect to happen, especially because we don't have any control over when atlases are loaded or unloaded.

    Also, taking a look at the reference tree, there are references that make absolutely no sense. Take, for instance, the first reference in the screenshot: Sprite < UUIButtonClickSound < Scene Object. While there are a few buttons with UUIButtonClickSound scripts attached, that script has exactly two fields and zero properties, none of which, as you might have guessed, has the type Sprite.

    We were able to observe a similarly strange reference chain using the new WIP memory profiler developed by Unity (see second screenshot). In that profiler, the reference is attributed to other game objects every time we load a level and take a snapshot, but none of these make more sense than the above one.

    Any idea on how to fix this?
     

    Attached Files:

    • 1.png
      1.png
      File size:
      100.8 KB
      Views:
      903
    • 2.png
      2.png
      File size:
      633.1 KB
      Views:
      891
    BTStone likes this.