OutOfMemory exception when loading bitmap from external storage

前端 未结 13 1743
广开言路
广开言路 2020-11-29 06:52

In my application I load a couple of images from JPEG and PNG files. When I place all those files into assets directory and load it in this way, everything is ok:

         


        
13条回答
  •  感情败类
    2020-11-29 07:13

    There are two issues here....

    • Bitmap memory isn't in the VM heap but rather in the native heap - see BitmapFactory OOM driving me nuts
    • Garbage collection for the native heap is lazier than the VM heap - so you need to be quite aggressive about doing bitmap.recycle and bitmap =null every time you go through an Activity's onPause or onDestroy

提交回复
热议问题