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

Are Packed Sprite pages always loaded ?

Discussion in '2D' started by JonPQ, Oct 25, 2016.

  1. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    So I'm trying to optimize a build.... it looks like some of the larger packed sprite pages are there right at app start bloating memory. But I thought Unity only loads the packed pages that it needs.. on a per-scene basis ?

    We bought tool ProfilerMemory which can do snapShots of currently used assets.
    It shows refs to all the sprites, as sprites (not as gameobjects or anywhere else, just sprites in the Project folder)

    So I tried making an empty scene, which only has a few cubes, and no Ui elements. I run profiler and take a memory snapshot, and it still says the big pages are in memory, but it looks different now. only 1 ref. (cachedSpriteAtlas) Which looks like the atlas itself... Does unity keep a ref to its own atlas so its always in memory ? or is this just the tool getting confused... and I can safely assume its not in memory if the only ref is (cached SpriteAtlas) ???

    So Why is it there ? why is it cached ? how can I get rid of these Packed sprite pages, so it only loads the ones that are needed? or so I can profile it properly please ?

    Help appreciated.
    Thanks much

    UNity 5.4.1f1 pro, Pc, building for Android
     
    Last edited: Oct 25, 2016
  2. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    ok so found it.... some code was loading object from resources to access data on it, that also had a ref to sprite on the sprite sheet... remove all reafs, and unity won't load it.