java.lang.OutOfMemoryError BitmapFactory.nativeDecodeAsset()

筅森魡賤 提交于 2019-11-30 19:14:40
Torid

The "bitmap size exceeds VM budget" error is actually in the native graphics library (Skia). It is a tad confusing as the problem is really that Skia has run out of memory in the native heap for bitmap data. See BitmapFactory OOM driving me nuts for background. To get round this, you will have to look carefully at your bitmap usage

  • making sure that you do not leave bitmap references floating
  • doing a recycle / null onn bitmaps as they become free (this appears to help).
Sam

Use sampling to read bitmap. May be error occurred due to memory leaks.

BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;

Bitmap bitmap=BitmapFactory.decodeFile(path,options);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!