Available app's memory during execution
How do I know how much memory is available for my app on the fly? My app downloads some bitmaps and saves (in memory) them so not to b开发者_开发问答ug the user by downloading it again. But the Java's heap is only 16MB, as far as I know, so I will need to handle some low memory cases and throw away some downloaded bitmaps (not all the bitmaps are shown at the same time, but they might be visible to the user with a single "click", if they are already downloaded).
Is there a way to get the actual available memory (which means, the Java heap available memory)?
A blog on Android memory
http://codelog.dexetra.com/post/47690459692/getting-around-android-memory-blues
check it out ..it may help u..
Instead of worrying about all this, consider wrapping the object that represents each image in a WeakReference. Then just do caching with Map<String, WeakReference<Image>>
or however you are doing it.
This way, if it's already in the cache, use it. If it's not in the cache (either it has never been accessed before or it's been GC'd) then get it again.
精彩评论