RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 408 forks source link

OutOfMemoryException when taking a picture #62

Closed metronidazol closed 7 years ago

metronidazol commented 7 years ago

I've got exception when called whenAvailable() on PendingResult:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:129) at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20) at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:841) Caused by: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError at java.util.concurrent.FutureTask.report(FutureTask.java:94) at java.util.concurrent.FutureTask.get(FutureTask.java:160) at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:127) at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)  at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)  at java.lang.Thread.run(Thread.java:841)  Caused by: java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:522) at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:540) at io.fotoapparat.result.transformer.BitmapPhotoTransformer.readImage(BitmapPhotoTransformer.java:53) at io.fotoapparat.result.transformer.BitmapPhotoTransformer.transform(BitmapPhotoTransformer.java:29) at io.fotoapparat.result.transformer.BitmapPhotoTransformer.transform(BitmapPhotoTransformer.java:14) at io.fotoapparat.result.PendingResult$1.call(PendingResult.java:55) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)  at java.lang.Thread.run(Thread.java:841) 

Is there any way to fix it?

dmitry-zaitsev commented 7 years ago

There are three ways to fix that: