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

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

Comments

  • 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
    http://msdn.microsoft.com/en-us/library/ms973837.aspx
Sign In or Register to comment.