I have a List container which can potentially have up to 100,000 items in to start with. While the program is running this list will slowly empty, should I alter the capacity as I empty the list?
I have done some testing and execution time seems to be the same, but is there much overhead to lowering the capacity of a list? I can find lots of information about increasing the capacity but not much on lowering it.
Unless you have a very low amount of memory, this is a micro-optimization.
Normally, there is no need to change the capacity of a
List<>.From the
TrimExcessmethod documentation: