Wednesday, June 16, 2010

[android-developers] Re: Bitmaps and OutOfMemoryError: Best Practices needed

On Jun 16, 3:43 am, Yahel <kaye...@gmail.com> wrote:
> Maybe you can tell us what the 4 mb pictures is used for.
>

It's a screen buffer. It's not useful to me unless it covers the
entire screen - and then some because of arbitrary rotation. So it can
easily be a 908x908 image on Incredible.

> Say if you are working on a game and it is your scrolling background,
> maybe you could use tiles instead and only have smaller chunks.
>

That's what the 25 or so chunks in number two are. But as pointed out
here, they can be taking up even more room, albeit in smaller chunks.
I believe the buffer saves me from rendering these 25 images and
hundreds of smaller ones, plus some lines and points each time. I
won't rule out eliminating the screen buffer, but I'd have to profile
it.


> I take it you also set the BitmapFactory.Options.inInputShareable to
> true so that BitmapFactory.Options.InPurgeable MIGHT not make a copy
> of the data ?
>
Yes. I set both of those. On 1.6 or higher that is.

I can see that it is likely that inPurgeable is not effective enough
for my cache of images in number two. If it were, there would be 6
megabytes of bitmaps that could be purged before returning failure.
Since it is a hint, it's certainly possible that the HTC Incredible
doesn't do much for it. If that holds up under analysis, then perhaps
the best scheme to force purgeability at certain times.

Nathan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment