Hi All,
We are observing a serious issue with the memory usage of Queue and its very critical issue which needs to be fixed.
We have an application which runs two threads i.e. a Producer and a Consumer thread. The Producer thread (Enqueue) inserts some heavy user defined object in the Queue. The Consumer thread (Dequeue) deletes one object from the Queue and processes it.
When we monitored the memory usage of this application in Task manager, we observed that there is a continuous rise in memory usage. After thousand insertions in the Queue, the Producer thread terminates and at this point the memory usage becomes constant. After deleting all the elements from the Queue, the Consumer thread also terminates.
However we observed that the memory usage for the application doesn't drop to the start value from where it has started even after removal of all elements from Queue. I implemented Dispose () for user defined classes and called GC.Collect (), GC.WaitForPendingFinalizers () and so that garbage collector should free all the memory taken up by the Queue. However after doing this, there is no drop observed in memory usage.
We also used ANT memory profiler tool in order to detect if there are live object references present in the queue, but the tool didn't showed any such live references.
One strange behavior we observed is, when the container object which has Queue object as a data member goes out of scope, Dispose () method does not get called for container object.But just before the termination of application, Dispose method gets called. Why the memory does not gets released or collected by GC when object goes out of Scope?
Is there any known memory accumulation problem with the Collection (i.e. for list, Queue and Arraylist) classes of .Net framework?