| Author |
Message |
jeggers
Joined: 24 Mar 2010 Posts: 5
|
Posted: Wed Mar 24, 2010 3:01 pm Post subject: 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 |
|
| Back to top |
|
 |
slaphead99
Joined: 10 Mar 2010 Posts: 93
|
Posted: Mon Apr 05, 2010 12:09 pm Post subject: |
|
|
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 |
|
 |
|
|
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