Author Topic: Atlas textures leaking?  (Read 3281 times)

cowlinator

  • Guest
Atlas textures leaking?
« on: April 29, 2013, 12:38:35 PM »
Our app is crashing on mobile devices due to memory issues.  We have 2 scenes that we are testing at the moment, scene 0, which has no NGUI elements, and scene 1, which has a large NGUI UI (multiple atlases).

In order to help figure out the problem, We are using a simple script which runs goes back and forth between scene 0 and scene 1, and each time records the results of  Object.FindObjectsOfType(typeof(Object)) and Resources.FindObjectsOfTypeAll(typeof(Object)).

We found that when the user goes from scene 1 back to scene 0 (non-additive scene load), while in scene 0 the atlases, atlas materials, and atlas textures are still loaded in memory.
(see http://docs.unity3d.com/Documentation/ScriptReference/Object.FindObjectsOfType.html and http://docs.unity3d.com/Documentation/ScriptReference/Resources.FindObjectsOfTypeAll.html )

We've tried manually calling Resources.Unload() on the materials/textures, to no avail.

We do have a couple of scripts we've called DontDestroyOnLoad() on, but they don't have reference to anything but primitive data types, and they don't share a gameObject with any other components. 

What can we do to unload these large asset textures from memory? 

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas textures leaking?
« Reply #1 on: April 29, 2013, 05:58:20 PM »
Choose Debug Info - Geometry on your panels. You will then see the hidden objects left by NGUI (UIDrawCalls). Make sure that at the time you are calling Resources.Unload() that there are no UIDrawCalls referencing the objects you are trying to unload.

cowlinator

  • Guest
Re: Atlas textures leaking?
« Reply #2 on: May 01, 2013, 12:12:27 PM »
Thanks for your help.  It turned out that one of our monobehaviours was retaining references to ui elements in non-static class fields after being destroyed, somehow.  This is what caused the texture leak.