I am sure this is not the perfect solution that you are looking for
but here's a workaround that I've used.
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 4;
bitmap = BitmapFactory.decodeByteArray(data, 0,
data.length,options);
I can sample the image to adjust the pixels of an bitmap and so the
size of the bitmap. This leads to lesser possibility of throwing an
OOM exp.
Let us know if it helped u or not...
On Dec 24, 2:20 am, GregAZ <[email protected]> wrote:
> I've been doing a lot of searching and I know a lot of other people
> are experiencing the same OOM memory problems with BitmapFactory. My
> app only shows a total memory available of 4MB using Runtime.getRuntime
> ().totalMemory(). If the limit is 16MB, then why doesn't the total
> memory grow to make room for the bitmap? Instead it throws an error.
>
> I also don't understand that if I have 1.6MB of free memory according
> to Runtime.getRuntime().freeMemory() why do I get an error saying "VM
> won't let us allocate 614400 bytes"? Seems to me I have plenty
> available memory.
>
> My app is complete except for this problem, which goes away when I
> reboot the phone so that my app is the only thing running. I'm using
> an HTC Hero for device testing (Android 1.5).
>
> At this point I'm thinking the only way around this is to somehow
> avoid using BitmapFactory.
>
> Anyone have any ideas on this or an explanation as to why VM won't
> allocate 614KB when there's 1.6MB of free memory?
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en