So, I wasn't really sure what to call this thread, so let me explain. I have an array of objects (reference-type) that I'm changing (both the contents and the number of things held by the array) once-per-update. I figure there are really two ways of handling this:
1.) create a new List<object> of the type I'll be using on each cycle (or clearing at the end of each cycle, after it has served its purpose and repopulate again during the next update).
2.) create a finite-sized array (object) that only increases in size when the current maximum has been reached (so that the size of the array will only ever reach the greatest size it has ever been). This method requires that a variable be used to count how many items are currently stored in the array (because array.Count() will return the maximum size). Instead of clearing the contents or re-initializing the array, however, clearing this array (functionally), would simply require that the counting variable be set to zero. During the next update, when objects are being added, they simply replace whatever was previously in that spot.
The benefit of the first method is that it's empty when it's empty and only ever contains just what it needs to contain. I've heard/read (though I don't remember where), though, that dynamically-sized arrays are a little slower due to the increase in flexibility (needs to account for a broader set of circumstances). The second method doesn't use a dynamically-sized array, so, if that is true, it should hypothetically be faster. The caveat here is that it can still contain references to objects that the program is no longer using (because "clearing" the array doesn't de-reference them, but merely sets the count to zero). Because of this, the new keyword is rarely called (and is called less and less frequently as the size of the array increases).
My questions, then, are these: 1.) Are my assumptions about dynamic- vs. static-sized arrays correct? 2.) Which of these is likely to be faster, and is there a scenario that one may perform better (few objects held at a time) but less well in another scenario (many objects held at once). 3.) Are there other methods I'm not considering (I assume there are, but are they worth considering?)?