I found that when a text box is selected, there is a big purple spike in "GC Allocated" lane of the profiler everytime the caret blinks.
It also produces huge GC spikes after some time (up to 50ms in my project), which don't appear at all when the text box is not focused.
I tested this in the NGUI chat example, and I clearly saw the spikes when the text box is selected, then they disappeared after deselecting it.
Are you aware of this? Is there a way to fix it?
Edit:
I found out it's because of this in UIDrawCall, when a panel gets rebuilt:
mMesh.vertices = verts.ToArray();
mMesh.uv = uvs.ToArray();
mMesh.colors = cols.ToArray();
ToArray requires to put an array of the correct length, so the internal buffer of BetterList is shrunk to fit the actual size, not capacity, causing tons of GC, because:
if (size < buffer.Length)
{
T
[] newList
= new T
[size
]; for (int i = 0; i < size; ++i) newList[i] = buffer[i];
buffer = newList;
}
A way to avoid this would be to use the new SetVertices(List<Vector3>) but since BetterList is used everywhere in NGUI it's a lot of work.
Did anyone thought about this already?