File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Using WeakReferences in Android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Using WeakReferences in Android" Watch "Using WeakReferences in Android" New topic

Using WeakReferences in Android

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 782

I understand that WeakReferences are especially suited to implement Caches.

Are there other scenarios whereby WeakReferences are suitable on a mobile platform like Android ?
I understand that Android reclaims memory itself by killing processes.
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 423
Weak references are used to prevent circular references too.
Ed Burnette
Ranch Hand

Joined: Jun 10, 2003
Posts: 142
Android's Dalvik VM does garbage collection just like your desktop version of Java SE does.

In addition to that, when memory gets tight, paused applications can be killed. If they're needed later they are reconstituted from saved state.

Ed Burnette, Author of Hello Android
Blog: ZDNet's Dev Connection - Twitter: @eburnette
I agree. Here's the link:
subject: Using WeakReferences in Android
It's not a secret anymore!