Hi, some users reports Out of Memory when they use rotate of viewed image. On my device (Samsung Galaxy Note II) is this problem too. I tested it on version 2.3.0 also but this problem is there still.
Rotate button has this simple functionality:
I add logs to SubsamplingScaleImageView.BitmapTileTask.doInBackground() to synchronized block before decodeRegion and before createBitmap with tag SUBSAMPLING ROTATE (this is in exception log below).
The proble is that bitmap gets big dimensions from decodeRegion - dimensions are original of image source with sampleSize = 1.
Is there another procedure for change orientation for eliminate Out of Memory?
D/SUBSAMPLING ROTATE﹕ tile: Rect(0, 0 - 2448, 3264); sampleSize: 1
D/dalvikvm﹕ GC_FOR_ALLOC freed 5088K, 41% free 27412K/45956K, paused 25ms, total 26ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 43.484MB for 15980560-byte allocation
D/dalvikvm﹕ GC_FOR_ALLOC freed 329K, 31% free 42689K/61564K, paused 17ms, total 17ms
D/SUBSAMPLING ROTATE﹕ bitmap dim: 3264 x 2448
D/dalvikvm﹕ GC_FOR_ALLOC freed 1K, 31% free 42689K/61564K, paused 15ms, total 15ms
I/dalvikvm-heap﹕ Forcing collection of SoftReferences for 15980560-byte allocation
D/dalvikvm﹕ GC_BEFORE_OOM freed 70K, 31% free 42618K/61564K, paused 27ms, total 27ms
E/dalvikvm-heap﹕ Out of memory on a 15980560-byte allocation.
I/dalvikvm﹕ "AsyncTask #2" prio=5 tid=12 RUNNABLE
I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0x4368dde0 self=0x5b526ce0
I/dalvikvm﹕ | sysTid=31125 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1532129584
I/dalvikvm﹕ | state=R schedstat=( 562850949 168737745 1402 ) utm=46 stm=10 core=3
I/dalvikvm﹕ at android.graphics.Bitmap.nativeCreate(Native Method)
I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:636)
I/dalvikvm﹕ at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView$BitmapTileTask.doInBackground(SubsamplingScaleImageView.java:1197)
I/dalvikvm﹕ at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView$BitmapTileTask.doInBackground(SubsamplingScaleImageView.java:1167)
I/dalvikvm﹕ at android.os.AsyncTask$2.call(AsyncTask.java:287)
I/dalvikvm﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:234)
I/dalvikvm﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
I/dalvikvm﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
I/dalvikvm﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
I/dalvikvm﹕ at java.lang.Thread.run(Thread.java:841)
I/dalvikvm﹕ [ 03-09 10:24:31.503 31026:31125 W/dalvikvm ]
threadid=12: thread exiting with uncaught exception (group=0x4195b700)
E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
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.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
at android.graphics.Bitmap.createBitmap(Bitmap.java:636)
at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView$BitmapTileTask.doInBackground(SubsamplingScaleImageView.java:1197)
at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView$BitmapTileTask.doInBackground(SubsamplingScaleImageView.java:1167)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
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)
D/xxxFragment﹕ onPause
I/com.sjl.util.Foreground﹕ still foreground
V/GAV4﹕ Thread[GAThread,5,main]: Loaded clientId
D/xxxFragment﹕ onDetach
E/ViewRootImpl﹕ sendUserActionEvent() mView == null
Thanks...
EDIT 1: for this is not relevant if image is zoom out or in in view component.
EDIT 2: btw this exception is catched for Exception in BitmapTileTask.doInBackground(), but OutOfMemory is not its child and because it is in async task it is not possible catch in my application. Please add catching OOM.