image - Android - Too much memory consumed by changing ImageView drawable -


in android app have custom imageview which, based on user interaction, needs update image. imageview can have 2 images, represent , front of card. so, when user clicks button need show of card (set custom's imageview image of card , when user cliks button again, set front image imageview drawable).

in order accomplish have 2 methods in custom imageview:

public void showback() {     setimageresource(r.drawable.card_back); }  public void showfront() {     setimageresource(r.drawable.card_front); } 

of course, works great, memory consumption of app near 114 mb, , increases user clicks button (rotates card).

due that, think problem produced change of image. images small, 1 104.6kb , other 80.4kb (png format), don't understand why app consuming memory (maybe because images allocated times , never recycled?, or maybe because of android's cache system of drawables?)

so, can solve problem?

thank you.

image dimensions 335 x 501

the size of images don't play of role here. dimensions on other hand do. if using images large dimensions , using them in imageview smaller resolution, problem , might end having oom (out of memory exception).

please see: http://developer.android.com/training/displaying-bitmaps/index.html


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -