Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Posts: 1
Joined: Mon Mar 10, 2008 6:43 pm


Post by smorgan » Mon Mar 10, 2008 6:48 pm

I am trying to figure out why a class instance is hanging on to an apparently weak reference to an instance of type List<T>. In the class's Dispose method I am explicity calling the Clear() method for this private variable and then assigning it a null value. However, I continue to see the instance in the profiler referenced by Object[], which shows List<WeakReference>..cctor() in its allocation stack.

Am I missing something? Any help would be greatly appreciated. Thanks in advance...[/img]

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Tue Mar 11, 2008 9:22 pm

Are your actually seeing an instance of List<T> in your process? As far as I can see, no such instance is created in the List<T>..cctor.

The only instance I can see that the class constructor of List<T> creates, is an empty array of T. The array is referenced by a static field (List<T>._emptyArray) and will be kept alive until the application domain exits. This single empty array does not indicate a memory leak and is only used for performance reasons.

To be able to investigate the problem further, it would be good if you could post the allocation call stack of the List<T> instance, and one or more root paths.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 15 guests