Author Topic: GC Alloc each frame  (Read 16917 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GC Alloc each frame
« Reply #15 on: March 05, 2014, 08:31:57 AM »
Yes, and try using that with a scroll view.

In a scroll view when you are dragging something, ALL items are visible, resulting in a very large draw call. When you stop dragging, items get culled and the buffer returns to a much smaller version. In your case the buffer will always be large.

Furthermore draw calls are recycled, so if you have one large scroll view it may cause all of your other draw calls to become huge in size as well because you never release the memory.

GavinWoods

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: GC Alloc each frame
« Reply #16 on: March 05, 2014, 09:31:40 AM »
Im currently not using ScrollViews and dont think I have need to. You think its ok to keep it like this for now? The GC allocations were dropping our game from 60-30 and this has resolved it. In between scenes I will most likely Trim the buffers manually to stop them getting too large. As for now though it seems pretty steady at 128 allocations.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: GC Alloc each frame
« Reply #17 on: March 05, 2014, 01:54:21 PM »
You can always do something like periodic calls to trim things if you want; like when you switch from one screen to another, or when a game ends or whatever - a convenient loading place. A hiccup isn't felt during a transition.

blechowski

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: GC Alloc each frame
« Reply #18 on: March 06, 2014, 03:40:24 AM »
Yes, and try using that with a scroll view.

In a scroll view when you are dragging something, ALL items are visible, resulting in a very large draw call. When you stop dragging, items get culled and the buffer returns to a much smaller version. In your case the buffer will always be large.

Furthermore draw calls are recycled, so if you have one large scroll view it may cause all of your other draw calls to become huge in size as well because you never release the memory.
Could we get a feature that would allow us to regulate this behavior?

Maybe a flag in UIPanel: AutoTrimBuffers on/off?
And an interface to trim the buffers manually would be nice.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GC Alloc each frame
« Reply #19 on: March 06, 2014, 11:04:06 AM »
Currently trimming doesn't happen unless the buffer is less than half of what it used to be in size:
  1.                                 // If the number of vertices in the buffer is less than half of the full buffer, trim it
  2.                                 if (!trim && (verts.size << 1) < verts.buffer.Length) trim = true;
So unless the buffer size keeps changing drastically, this shouldn't be an issue at all.