The real Java doc is a bit better: http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/ref/WeakReference.html
A WeakReference is an object that contains within it a reference to another object. The reference is treated specially by the garbage collector in that its existence doesn't prevent the object from being deleted (though any other "real" reference will). But, if the object IS deleted, the garbage collector nulls the pointer in the WeakReference. You can examine the actual object reference using the ref() method. You might, eg, create a cache (say, of URLs resolved to IP addresses by network name lookup) by using a hashtable of String - >WeakReference. When you want to reference something you look it up in the hashtable and, if not found, create it. Later, when you look again and find the hashtable entry you check ref() and treat it as "not found" if the ref() is null, otherwise use the ref() value to reference the object. Garbage collection will preferentially not delete objects referenced from WeakReferences, but may eventually delete them, after several GC cycles of being otherwise unreferenced. On Jul 22, 12:48 pm, GodsMoon <[email protected]> wrote: > Google just posted a new blog post > onhttp://android-developers.blogspot.com/2010/07/multithreading-for-per.... > I understand the AsyncTask and I'm even using one in a list with > images already. > > But I don't understand what a WeakReference is. I gather is is a > garbage collector directive, but I thought I didn't need to manage > garbage collection on Android. > > http://developer.android.com/reference/java/lang/ref/WeakReference.html > isn't as helpful as I was hoping it would be. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

