So in a .NET app , i got about 2 million items that i need to hold them in memory for processing , 1 by 1, would holding these items in a Stack collection , is better than holding them in a List collection, assuming that the memory used by the stack object will be keep minimizing every time an item is poped out of the stack object , or the memory allocated by the stack will keep the same till the stack is set to null, or cleared.
sorry if i couldn’t express the question in the right way.. but here is another way, when a Stack collection is used, does the memory used by the stack get minimized every time an item is pulled out of the stack.
Thanks in advance
No difference. The ‘Pop’ method of a Stack never reduces the size of the internal array. The ‘Push’ method doubles the size when the limit is hit.
I used .NET Reflector to discover this.