Hey Aren
After some hacking and twiddling ive come up with a solution to this. No idea if its perfect or what it'll break internally. In BetterList the trim methods were getting called when the list size shrunk which caused a re-alloc everytime.
I removed this call to make it retain the max memory it has allocated thus no re-allocation is needed. I also increased the initial allocation on better list to 64 and the max check now clamps to 128. Might be overkill.
Like I say I dont know if this trimming causes issue elsewhere but this has completely removed and GC allocations NGUI was causing in re-building.
Here is what I changed inside BetterList:
void AllocateMore ()
{
T
[] newList
= (buffer
!= null) ? new T
[Mathf
.Max(buffer
.Length << 1,
128)] : new T
[64]; if (buffer != null && size > 0) buffer.CopyTo(newList, 0);
buffer = newList;
}
/// <summary>
/// Trim the unnecessary memory, resizing the buffer to be of 'Length' size.
/// Call this function only if you are sure that the buffer won't need to resize anytime soon.
/// </summary>
void Trim ()
{
//if (size > 0)
//{
// //if (size < buffer.Length)
// //{
// // T[] newList = new T[size];
// // for (int i = 0; i < size; ++i) newList[i] = buffer[i];
// // buffer = newList;
// //}
//}
//else buffer = null;
}