Closed francescodeliva closed 4 years ago
I used this algorithm to calculate max memory:
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
manager.getMemoryInfo(memoryInfo);
totalSystemByteAvailable = memoryInfo.totalMem;
treshold = memoryInfo.threshold;
options.inAvailableMemory = totalSystemByteAvailable - treshold;
We are going to test this code. Thanks
I have experienced a permanent OutOfMemory calling this method: TiffBitmapFactory.decodePath(path);
It happens only on the following devices that I use to test Android 4.:
This is the stack trace of the java.lang.OutOfMemoryError:
android.graphics.Bitmap.nativeCreate (Bitmap.java)
| android.graphics.Bitmap.createBitmap (Bitmap.java:817) | android.graphics.Bitmap.createBitmap (Bitmap.java:794) | android.graphics.Bitmap.createBitmap (Bitmap.java:761) | org.beyka.tiffbitmapfactory.TiffBitmapFactory.nativeDecodePath (TiffBitmapFactory.java) | org.beyka.tiffbitmapfactory.TiffBitmapFactory.decodePath (TiffBitmapFactory.java:157)
I succeeded to avoid the OutOfMemory crash by setting this attribute of Options: options.inAvailableMemory = 20000000;
But the returned Bitmap is null.
How can I find a runtime value of options.inAvailableMemory that will work without returning a null bitmap?
Should I use this information? https://developer.android.com/reference/android/app/ActivityManager.MemoryInfo.html
Thanks Francesco