I have a photo editing app. When I import an image, it works fine but, opening up the image for editing causes it to crash.
This is the logcat output:
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
UPDATE::
@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);
}
}
this is my onResult code .. so the choosenBitmap displays on the imageView ( ivPhoto ) I need to use .recycle(); so i free up some memory by recycling the already imageView .. where do I use the .recycle(); ? I tried to change the .setBackgroundColor(0); to .recycle(); but it doesn't work