Does C# Array resize take longer the bigger the array?
arrays, c#
Solution
It should do yes, resizing involves allocating new memory to the size you want and copying the old array into the new one. The larger the array, the more to copy.
From MSDN:
This method allocates a new array with the specified size, copies elements from the old array to the new one, and then replaces the old array with the new one.
Without knowing too much about the code, try using `List<T>` to manage the list and the resizing you need to do and when you need to provide it to Unity, call `list.ToArray();`.
This will still create the array and copy it, but only once per frame.
Problem
In my application I do System.Array.Resize once per frame. Initially I set my arrays to a maximum possible size, and then Resize them to something smaller. In some cases it may be a lot smaller, in others it may be just a little smaller. It appears to me though that the more elements there are to resize, the longer it takes. Perhaps my observations are wrong, and that is why I am asking here.