Thursday, September 22, 2011

[android-developers] Re: How to resolve outOfMemoryError - Bitmap size exceeds VM budget

I had a similar problem to yours, and what i tried is that whenever im
initializing all my elements (after the oncreate) I assign the
background in my activity and not in my XML. (at runtime)

and that's how I fix my outofmemory..
hope this helps

On Sep 22, 8:16 am, joaocruz04 <jtcru...@gmail.com> wrote:
> Hi all,
> i've been searching the web for a solution but i couldn't find one.
> Most of the solutions are for the case when the screen orientation is
> changed, and then, reimplement onDestroy method. But that's not my
> case.
>
> I have the case where i have let's say, 10 activities, one leading to
> another.
> Each one has a different background (from a drawable), and each one
> has a image with 700px by 200px (big resolution for big resolution
> devices).
>
> Both images and background are defined in the respective layout xml.
>
> The thing is, when reaching activity 7 or 8, it gives me the
> outOfMemory error. I know it's because of the large amount of images.
>
> Tried to implement onPause and onResume, but then it gives me some
> errors like trying to use a recycled drawable.
>
> I want to preserve the images, because i may want press "back" and
> return to the last activity.
>
> What's the best way to deal with this?
>
> How can i "free" an activity from it's background and image when its
> paused, and then when the activity resumes, put the background and
> images back again?
>
> Thanks in advance,
> João Cruz

--
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