Author Topic: Memory Leak found in NGUI so it seems  (Read 4531 times)

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Memory Leak found in NGUI so it seems
« on: April 23, 2015, 11:49:15 PM »
Our project is almost done! OMG 1.5 years. Loving NGUI every day of it. Ok enough compliments. We are in the memory\performance tuning point of this sucker.

If i run on device(even on windows it does this) I can detect orphaned game objects in the scene. The  number of them grows consistantly, after just 2 level changes I had 44 of them. They do not go away on a scene change. I went back to a "rest" scene that is mostly empty and printed out debug info on them. Here is what I was able to get. I was able to find these using the unity profiler, taking a memory snapshot and looking in the GameObjects section of Scene Memory, there it lists them all as being named "New Game Object"

I am setting their  name so I can tell them apart, then printing their children, parent and components.
DEBUG: Named Him:Found:44, active=True parent = null child count = 0 children = components=,Found:44-UIDrawCall

You can see here that its a root game object who has a component inside of him that appears to be himself???? That's really strange... The type was UIDrawCall

The code I used to find this is:
  1. GameObject[] gos = Resources.FindObjectsOfTypeAll<GameObject>();
  2.  
  3.  
  4.  
  5. public void DescribeGameObject(GameObject go, int count)
  6.     {
  7.         go.name = "Found:" + count;
  8.         string childrenNames = "";
  9.         for (int i = 0; i < go.transform.childCount; i++)
  10.         {
  11.             childrenNames = childrenNames + "," + go.transform.GetChild(i).gameObject.name;
  12.         }
  13.         string componentNames = "";
  14.         foreach (Component c in go.GetComponents<MonoBehaviour>())
  15.         {
  16.             componentNames = componentNames + "," + c.name+"-"+c.GetType().Name;
  17.         }
  18.         Utils.DebugLog("Named Him:"+go.name+", active=" + go.activeInHierarchy + " parent = "+((go.transform.parent == null) ?"null":go.transform.parent.name)+" child count = " + go.transform.childCount + " children =" + childrenNames + " components=" + componentNames);
  19.     }
  20.  

If this is already fixed, I apologize. I am somewhat up to date, my NGUI version is 3.8. This seems like a pretty serious issue as in only 3 levels I had 44, and just a few minutes of the game running. Imagine if it ran for an hour....

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Memory Leak found in NGUI so it seems
« Reply #1 on: April 24, 2015, 05:45:37 AM »
UIDrawCalls are cached and reused and not shown in the hierarchy, so this is likely what you're seeing.