Remove WeakReferences

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
hemant960
Posts: 2
Joined: Wed Apr 20, 2011 10:25 am

Remove WeakReferences

Post by hemant960 » Wed Apr 20, 2011 10:34 am

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
Attachments
memory.PNG
Weakreferences
memory.PNG (4.71 KiB) Viewed 6748 times

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

Re: Remove WeakReferences

Post by Andreas Suurkuusk » Thu Apr 21, 2011 6:01 am

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.
Best regards,

Andreas Suurkuusk
SciTech Software AB

hemant960
Posts: 2
Joined: Wed Apr 20, 2011 10:25 am

Re: Remove WeakReferences

Post by hemant960 » Thu Apr 21, 2011 10:51 am

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

Post Reply

Who is online

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