ViewSpreadTranslationController icon indicating copy to clipboard operation
ViewSpreadTranslationController copied to clipboard

OOM 内存溢出

Open shikechen opened this issue 7 years ago • 0 comments

java.lang.OutOfMemoryError: Failed to allocate a 8294412 byte allocation with 8279288 free bytes and 7MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:1071) at android.graphics.Bitmap.createBitmap(Bitmap.java:1041) at android.graphics.Bitmap.createBitmap(Bitmap.java:1008) at helper.AbstractViewHelper.getBitmapWithView(AbstractViewHelper.java:124) at helper.BaseViewHelper.backActivity(BaseViewHelper.java:299) at helper.BaseViewHelper.backActivity(BaseViewHelper.java:333)

问题出现的操作: 连续操作几次进入页面再退出时出现。

问题相关代码: AbstractViewHelper.class protected Bitmap getBitmapWithView(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); // 引起OOM的代码 Canvas canvas = new Canvas(bitmap); v.draw(canvas); canvas.setBitmap(null); return bitmap; }

BaseViewHelper.class public void backActivity(Activity mActivity, int resultCode, Intent mIntent) { //省略部分代码 inflate.setBackgroundDrawable(new BitmapDrawable(getBitmapWithView(viewGroup))); //省略部分代码 }

shikechen avatar Sep 01 '18 10:09 shikechen