android - ArrayList of Drawable or ArrayList of Bitmap? -


i getting 1 scenario have store images in arraylist (bitmap or drawable). when bitmaps come mind think memory issues outofmemory. arraylist of drawable make difference? or arraylist of bitmap? should use?

this interesting question ... generalizing answer don't know why need use list of drawable/bitmap.

to honest wouldn't use neither of them because:

  1. bitmaps: these objects occupy lot of memory , storing these in memory can harmful sure sooner or later if you're not careful. example: maybe send list through intent different component. if , initial list not destroyed you'll case have doubled amount of memory bitmaps deserialized new objects on target component side.
  2. drawables: bitmapdrawable keeps reference bitmap, don't see provide benefit on bitmap itself. may "forget" clear list of drawables , way you've memory leaked bitmaps. don't think creating drawable time consuming or resource consuming make worth caching.

to add more, have cover cases activity destroyed, re-created don't leak list.

personally speaking, bitmaps downloaded network, rather use lrucache store bitmap, assign keys them , backing them disk cache. assign keys each of them , work these keys. there libraries disklrucache, picasso or novoda-imageloader lot.

same applies resource bitmaps: work keys - no need cache them. resource images should small enough device size + density , big enough fit needs.

it's opinion ...


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -