Author Topic: UIDrawCall leaks if destroyed  (Read 2548 times)

Konstantin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
UIDrawCall leaks if destroyed
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrawCall leaks if destroyed
« Reply #1 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.

Konstantin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIDrawCall leaks if destroyed
« Reply #2 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 :-)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrawCall leaks if destroyed
« Reply #3 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.

Konstantin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIDrawCall leaks if destroyed
« Reply #4 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.