0

I'm trying to copy part of the source image. I've decoded the resource into bitmap with inScaling option turned off so I can crop from real image size but I'm getting outOfMemoryErorr thrown out.

I've read my device (S3) memory with

Log.i("CropParams memory", String.valueOf(Runtime.getRuntime().maxMemory()));

and it's showing 64MB.

I would really like to crop from real image size and to know what exactly causes outOfMemoryError so I know how to manage this kind of situations. This particular image is 2448x3264 and has 3.41MB.

Why is this particular image causing this error?

Thanks

Munez NS
  • 1,011
  • 1
  • 12
  • 31
  • as a side note, the size of the file (3.41MB) is totally irrelevant. The actual size of the decoded image is 2448*3264*4 = ~32MB – njzk2 Nov 14 '14 at 15:43

2 Answers2

0

See my answer on another question on how to dump the heap memory when you get an OutOfMemoryError. With the Hprof file you should be able to analyze the memory usage as described here.

Community
  • 1
  • 1
Guy B.
  • 611
  • 5
  • 10
0

I think looks like a job for the Region decoder. http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html

Just instantiate it with any of the newInstance api:s, then call decodeRegion for the region you are interested in.

Mattias
  • 2,272
  • 1
  • 15
  • 18