Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Konstantin on January 29, 2014, 07:22:20 AM

Title: UIDrawCall leaks if destroyed
Post by: Konstantin on January 29, 2014, 07:22:20 AM
From UIDrawCall

  1. static public void Destroy (UIDrawCall dc)
  2.         {
  3.                 if (dc)
  4.                 {
  5.                         if (Application.isPlaying)
  6.                         {
  7.                                 if (mActiveList.Remove(dc))
  8.                                 {
  9.                                         NGUITools.SetActive(dc.gameObject, false);
  10.                                         mInactiveList.Add(dc); // Leak!
  11.                                 }
  12.                         }
  13.                         else
  14.                         {
  15.                                 mActiveList.Remove(dc);
  16.                                 NGUITools.DestroyImmediate(dc.gameObject);
  17.                         }
  18.                 }
  19.         }
  20.  

Note that OnDestroy does not remove the UIDrawCall from any list. The UIDrawCall is stuck in the static mInactiveList until ReleaseAll is called which happens after last UIPanel is disabled.
Title: Re: UIDrawCall leaks if destroyed
Post by: ArenMook on January 29, 2014, 08:49:23 AM
That's not a leak. The inactive list is re-used when you re-enable another panel. NGUI doesn't re-create draw calls if it can reuse them.
Title: Re: UIDrawCall leaks if destroyed
Post by: Konstantin on January 29, 2014, 09:20:45 AM
Can I force a UIPanel to be destroyed completely with all its draw calls? I am absolutely sure that my draw call will not be reused and I want my 3MB of memory back :-)
Title: Re: UIDrawCall leaks if destroyed
Post by: ArenMook on January 29, 2014, 10:09:24 AM
UIDrawCall.ReleaseInactive() -- however I'm not sure if it's in the current public version. It's there in the Pro version though.
Title: Re: UIDrawCall leaks if destroyed
Post by: Konstantin on February 03, 2014, 06:18:53 AM
Updated to 3.4.8. Added following code...
  1. UIDrawCall.ReleaseInactive();
  2. Resources.UnloadUnusedAssets();
  3.  
...and the texture is gone from memory! Excellent. Thank you for support.