From Profiler I find that the atlas textures are never freed.(Even though I invoke Resources.UnloadUnusedAssets() manually)
And after multiple times of loading UI, Textures of memory will be larger and larger, and then crashed.
e.g
In scene1, I use atlas A,B,C.
Then I go to scene2, I only use altas C,D,E
But from Profiler, I find A & B still in the memory.
I’m not sure if this is a kind of GC strategy. But in Android platform, expecially for some devices which memory less than 1024MB, UGUI takes a lot of memory.
I created a new project for testing. And I find something interestring.
In scene1, I use atlas A.
In scene2, I use atlas B.
If I goto scene2 when ALL the image gameobjects in scene1 are active, atlasA will be freed.
BUT if even one of the gameobjects is deactive, altasA will always in the memory !
So I basically determined that this is a UGUI official bug.
I did.
The detail shows the atlas is reference by “ManagedStaticReferences”.
And I know this issue can also be seen while profiling in the editor.
Everytime I check the profiler, I restart Unity and make sure the profiler is exactly right.
ManagedStaticReferences – somewhere in your code, you are holding a static reference to a texture, or indirectly, to an object that holds the texture via some reference chain… You should first try to analyze whats holds references to any texture from that atlas.