Hi, I'm developing an app which uses ViewPager(holds 4 fragments) and a layout that hosts single-page fragments. I haven't populated my fragments with bitmap data but I'm already anxious about memory management.
Because of the bogus design I can't extract ViewPager to a separate activity which makes me do: setVisibility(View.GONE) on the ViewPager when I need to show a single-page fragment and vise-versa. Most of my fragments(both in ViewPager and single-page fragment holder) will hold bitmaps that'll be drawn from Internet. In most cases what I think I should do is: when fragment gets hidden - relevant bitmaps should be cleaned out of memory and brought back from SD-card/Internet when fragment gets shown again or implement somewhat like getMemory < memoryCredit ? keep : destroy; However I don't have enough experience with this and your suggestions are more than welcome. So far, I made an example where I hide fragments with either setVisibility or fragmentTransaction.hide and none of those two fire any callback like onPause which makes me think that I can't call recycle directly on the bitmaps. I've alsod looked into this library<https://github.com/thest1/LazyList>which makes use of private Map<ImageView, String> imageViews=Collections.synchronizedMap(new WeakHashMap<ImageView, String>()); and I assume that it means that GC gonna recycle those backbone bitmaps even without calling recycle - am I right ? However in class called MemoryCache he has private Map<String, Bitmap> cache=Collections.synchronizedMap( new LinkedHashMap<String, Bitmap>(10,1.5f,true)); and it's not weak - might that be a problem? Thanks. P.S. I have a bunch of small questions I couldn't figure out on my own: 1) Does ImageView.SetImageResource applied against the same id twice or thrice consumes memory for the same bitmap or uses a separate range for every imageview element ? 2) same as 1. but for BitmapFactory.decodeResource 3) What part of Bitmap object consumes the most memory. If it's "backbone memory object" than what is it ? Where can I elucidate the structure of bitmap memory for myself ? -- 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

