I'm getting quite crazy with this issue:
I am getting an OutOfMemoryError everytime I open my app. At some point, it loades an image from a server, but it's encoded y a Base64 string.
Whay I do is basically:
decodedString = Base64.decode(imagen_codificada);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0,
decodedString.length);
But i'm getting the damned OOME, everytime.
If tried with this:
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Even setting options to 128, what is crazy, but still crashes...
Is there a way to reduce the size of the String codifying the image somehow before decoding it? I can't operate straightly with the image, because it's used for many other things withing the app and in desktop environments...
I attach the ERROR log:
12-21 10:36:27.032: E/dalvikvm-heap(5508): 10119168-byte external allocation too large for this process. 12-21 10:36:27.032: E/dalvikvm(5508): Out of memory: Heap Size=5823KB, Allocated=4351KB, Bitmap Size=720KB, Limit=13692KB 12-21 10:36:27.032: E/dalvikvm(5508): Trim info: Footprint=6343KB, Allowed Footprint=6343KB, Trimmed=520KB 12-21 10:36:27.032: E/GraphicsJNI(5508): VM won't let us allocate 10119168 bytes 12-21 10:36:27.192: E/AndroidRuntime(5508): FATAL EXCEPTION: main 12-21 10:36:27.192: E/AndroidRuntime(5508): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
EDIT: SOLVED WITH THIS:
decodedString = Base64.decode(imagen_codificada);
System.gc();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
InputStream input = new ByteArrayInputStream(decodedString);
Bitmap decodedByte = BitmapFactory.decodeStream(input, null,
options);
menu.setNombreApellido(decodedByte);
Thanks to everyone!!