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

Some resources are not unloaded after changing scenes

Discussion in 'Editor & General Support' started by dotsquid, May 30, 2019.

  1. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    I discovered this weirdness with a help of Memory Profiler. Please, take a look.
    Here is a Texture2d used by an atlas which in turn is used in one of the scenes.
    I loaded that scene and then replaced it with another one which does not use this texture. Then I made a snapshot (everything is done in development build, not the editor).

    Pay attention on the RefCount - 352
    upload_2019-5-30_15-3-56.png

    Let's see who is referencing this texture.
    upload_2019-5-30_15-5-44.png

    Obviously it's a SpriteAtlas itself and each Sprite in that atlas. 351 sprites + 1 atlas = 352.
    Please note that I sorted the RefCount in descending order. Each sprite has RefCount == 1 meaning that only SpriteAtlas is referencing each of those sprites.
    So it appears that we have a circular dependency between Sprites, SpriteAtlas and Texture2d, but no object "outside" has a reference to either of these objects.

    Any ideas?
     

    Attached Files:

  2. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Anyone?
     
  3. gianfanatee

    gianfanatee

    Joined:
    Jun 14, 2016
    Posts:
    13
    Hi there, dotsquid. Were you able to solve this problem? I'm currently stuck with the same issue
     
  4. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Hi, gianfanatee. Nah, had to release the game with this weird behavior.
    I hope I'll find some time for deeper investigation.