Some backgroud:
I am looking at the various collection objects available to me in the .NET framework and trying to make a decision on which one to use.
I have to go through each object in a collection, not necessarily enumerate through them, process, and remove it. I have to do this in memory and the dataset will be large (closing in on a gig). I need my memory footprint to reduce as quickly as possible.
Question:
Does dequeue’ing an object from the Queue collection free that reference in the queue so the garbage collector can do its job? (assuming no other reference to the dequeued object)
If you’re talking about the built-in
Queue<T>andQueuecollections then yes, when an object is dequeued then the element in the backing array that previously held that object is set todefault(T)/null, which should allow the object to be subsequently collected.