Android bitmap processing - no leak but still OOM? -


i'm writing camera app , when take picture, receive byte [], decode bitmap , rotate before saving jpeg. i'm rotating photo using native library, bitmap still decoded byte[] memory (still, allows me keep 1 bitmap instead of 2). there's 1 place in code require lot of memory , oom on devices heap low , cameras stupid-megapixels. suggestions how fix without on loosing image quality?

i don't think want use largeheap="true" should forget rotation , set exif?

also i'm not keen on trying 'predict' if oom math's not adding up: android outofmemory when gc reports free memory?

any suggestions how fix without on loosing image quality?

use android:largeheap="true".

or, use other native library allows hand on byte[] , rotation , saving disk you, avoid bitmap , java-level processing of huge thing.

or, if minsdkversion 19, , rest of logic supports it, use inbitmap on bitmapfactory.options try reuse already-allocated bitmap object rather allocate fresh one. option available on earlier versions of android, has exact match in terms of resolution; on 19+, bitmap reused has big enough handle trying load it.

i don't think want use largeheap="true"

it may not (not devices give larger heap), , there costs user larger heap limit. being said, manipulating big camera images difficult without more memory, whether in java heap or represents allocations os native code.

should forget rotation , set exif?

that's possibility, though various things, imageview, seem ignore exif headers.

i'm not keen on trying 'predict' if oom math's not adding up

in part, that's because dalvik not have compacting/moving gc, , art has 1 while app not in foreground. outofmemoryerror means there no single contiguous free block of memory trying allocate.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -