Images Memory Management in Android

前端 未结 3 1571
醉酒成梦
醉酒成梦 2021-01-25 13:40

This is one of the most asked question by beginners but still I couldn\'t get any help unfortunately. In an activity I have a viewflipper to which I assign imageviews with imag

3条回答
  •  滥情空心
    2021-01-25 13:58

    Now what happens over here is every app in android is alotted a specific amount of heap size that is as little as 20mb

    Bitmaps take up a lot of memory, especially for rich images like photographs

    so whenever you load a heavy image or array of heavy images it exceeds the heap size and android automatically shuts down the app because it was using more than the allotted heap size

    Read Documentaion

    So whenever you are working with heavy images

    • Load a scaled down version
    • Asynchronously process the image
    • and then final display it in an imageview

提交回复
热议问题