Question about memory profiling of collections

I'm currently having issues with tracking down the memory usage of a simple collection class in a WPF application. I'm using C#, .NET 3.5.

I'm creating a local List collection of a simple object that consists of 4 strings. I'm not actually adding any items to the list, but even though the List is defined as a local variable to the method, it would appear that the Memory Profiler is reporting that I have a live object of the List after the method and exited. I've tried forcing a GC but the List object remains.
Having replaced the List with an ObservableCollection, the results are the same.
Replace that with a simple array of the same simple object, and the Memory Profiler reports that I don't have any list instances of that array.
Is there a known issue with the Memory Profiler and Collections, and am I chasing a memory leak that isn't really there?




  • Hello Jonathan,

    no there are no known issues of the memory profiler giving spurious information of this nature. Something is still maintaining a reference to those generic collections. I think you should be able to get a "second opinion" on this simply by loading up those collections with multiple objects and observing the memory usage in Windows task manager.

    Hope this helps.
Sign In or Register to comment.