Red Gate forums :: View topic - GC Root Object: What does Yes - Weak Reference mean?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
ANTS Memory Profiler Previous Versions
ANTS Memory Profiler Previous Versions forum

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

Search in ANTS Memory Profiler Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
jeggers



Joined: 24 Mar 2010
Posts: 5

PostPosted: Wed Mar 24, 2010 3:01 pm    Post subject: GC Root Object: What does Yes - Weak Reference mean? Reply with quote

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
Back to top
View user's profile Send private message
slaphead99



Joined: 10 Mar 2010
Posts: 93

PostPosted: Mon Apr 05, 2010 12:09 pm    Post subject: Reply with quote

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-weakreference-gc-knows-bes
http://msdn.microsoft.com/en-us/library/ms973837.aspx
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group