0

Let's say i have 10 activities, and each contain a static image, I am finishing and starting a new activity on left and right click of the arrow.enter image description here

Images are in drawable folder and are a bit large size, As far as i think, if a activity finishes then all the memory it's using is freed(that's why i had taken so many activities), but it's not happening.

If constantly go on clicking the right and left button, the app freezes and crashes(out of memory exception).

Is there any way to avoid this?

zaiff
  • 999
  • 2
  • 13
  • 29
  • Have a look at this link http://stackoverflow.com/questions/11949234/androidissue-image-resolution/11949665#11949665. With the help of this, to some extent you can avoid OME – Braj Sep 21 '12 at 06:57
  • what does "static image" means for you? – Blackbelt Sep 21 '12 at 07:22
  • static means thos are not downloaded from any url its present in the drawable folder of the project and set in the xml. – zaiff Sep 21 '12 at 07:33

1 Answers1

0

1- Load your images using:

BitmapFactory.decodeResource(res, id, opts);

Use inSampleSize in Options to rescale your image.

2- Recycle your bitmap in onDestroy().

Benito Bertoli
  • 25,285
  • 12
  • 54
  • 61