我有一个照片编辑应用程序。当我导入图像时,它可以正常工作,但是打开图像进行编辑会导致它崩溃。
这是 logcat 输出:
08-04 20:56:16.973: E/dalvikvm-heap(336): 810000-byte external allocation too large for this process.
08-04 20:56:17.073: I/dalvikvm-heap(336): Clamp target GC heap from 25.289MB to 24.000MB
08-04 20:56:17.073: E/GraphicsJNI(336): VM won't let us allocate 810000 bytes
更新::
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK
&& null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
ImageView imageView = (ImageView) findViewById(R.id.ivPhoto);
chosenBitmap = superDecodeFile(new File(picturePath));
imageView.setBackgroundColor(0);
Bitmap bMap = Bitmap.createScaledBitmap(chosenBitmap, 500, 500, true);
imageView.setImageBitmap(bMap);
}
}
这是我的 onResult 代码.. 所以我需要使用 .recycle(); 所以我通过回收已经存在的 imageView 来释放一些内存 .. 我在哪里使用 .recycle(); ? 我试图改变 .setBackgroundColor(0); 回收利用(); 但它不起作用