Search Unity

UI Garbage Collection

Discussion in 'UGUI & TextMesh Pro' started by yudixiaok, Apr 26, 2016.

  1. yudixiaok

    yudixiaok

    Joined:
    Aug 29, 2014
    Posts:
    17
    So i recently started optimizing my game by reducing the number of Garbage Collector calls and I noticed, that set the UI elements to parent will trigger a GC call.

    As can be seen in the attached picture that every time I set the parent of an UI element, the GC allocs 8.7kb. I don't know if it intended or it is a bug, but if I have many UI elements and manipulate their properties over time I will get a huge amount of GC calls.
     

    Attached Files:

  2. Tbaggi

    Tbaggi

    Joined:
    Aug 4, 2012
    Posts:
    14
    Can you post all the code concern by this please? (UIMiniMapPanel.SpawnItem() function)

    I use SetParent with UI elements in my code too and this is not as much GC expensive as yours.