Page 1 of 1

Remove WeakReferences

Posted: Wed Apr 20, 2011 10:34 am
by hemant960
Hi,

In .net memory profiler under call/stack method tab when I click on a method It shows me live instances.
I have attached screen shot of that live instances.
I want to know what is the meaning of this same number of weakreferenc and <gchandles>.
Please explain how to overcome this memory leak .

Thanks,
Hemant

Re: Remove WeakReferences

Posted: Thu Apr 21, 2011 6:01 am
by Andreas Suurkuusk
The <GCHandle> type is not a real .NET type, it represents the internal GC handle that is used internally by the runtime. A <GCHandle> can be created using the struct System.GCHandle and the WeakReference class. Since WeakReferences are implemented using <GCHandles>, you will always have one <GCHandle> for each WeakReference. In your case, you have selected a method that creates a set of WeakReferences (and indirectly a set of <GCHandles>). Whether this is a memory leak or not cannot be decided using the information you provided. I recommend that you investigate the details of the WeakReferences. The root path of the WeakReference will tell you why it has not been GCed, and hopefully this will help you find out whether it is mistakenly prevented from being GCed (i.e. if it's a memory leak), or if the WeakReference is still being used.

Re: Remove WeakReferences

Posted: Thu Apr 21, 2011 10:51 am
by hemant960
Hi,
Thanks for reply.
I have clicked on weakreference and it shows following detail.
Controls.Checkbox..ctor() userCheckbox.vb
Checkbox __ENCList Object[] #419[350]

Can you please explain me what is shows as I am new in .net profiler .

Thanks ,
Hemant