GC Root Object: What does Yes - Weak Reference mean?

Memory profiling for .NET developers

GC Root Object: What does Yes - Weak Reference mean?

Postby jeggers » Wed Mar 24, 2010 2:01 pm

I have some objects hanging around, the instance list shows (in the GC Root Object column): "Yes - Weak Reference". Does the "Weak Reference" mean I don't have to worry about them and they'll eventually be GC'd ?
l'essentiel est invisible pour les yeux
Posts: 5
Joined: Wed Mar 24, 2010 1:59 pm

Postby slaphead99 » Mon Apr 05, 2010 11:09 am

In answer to your question, yes.

A weak reference, is a reference that isn't strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector's ability to determine reachability for you, so you don't have to do it yourself.
To get a definitive answer you'd have to look into exactly how GC works in .net. In theory weak references can be cleared up at any time.

You're highly unlikely to encounter a memory leak due to weak references, but calling dispose on the objects should eliminate them anyway. For more information, I suppose you could look at these articles:

http://dotnet.dzone.com/news/net-weakre ... -knows-bes
Posts: 92
Joined: Wed Mar 10, 2010 1:27 pm

Return to ANTS Memory Profiler Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests