2

I'm developing an android app that takes photos from camera or from library and does some stuff on them. The point is that after some use the application crashes. I have tried to make every possible optimization I could think of, ex call gc when possible, null the images when I leave an activity and even remove activities from the cache. But I still get out of memory errors and the app crashes.

Any suggestions on how to avoid such errors? Or even how to efficiently load images from drawables folder . Or any efficient way to throw all not needed objects when the activity changes so as to only use the needed memory for the active activity??

1
  • Bitmap.recycle() is your friend to optimize memory use. Commented Feb 7, 2012 at 17:12

2 Answers 2

1

i had similar problems and ended up tracking them down to particular images. out of my 400 images there where three that where huge (file size wise). so i would check that all of your images have similar file size (usually it is directly correlated with image size)

also aren't bitmaps pretty big? how big is your average picture?

Sign up to request clarification or add additional context in comments.

4 Comments

My Images are kind of like a wallpaper for each activity and they are 640x960px size and arround 250kB in size.
ya that shouldnt be an issue then. i had images of like 5mb that caused my problems. just to double check though, they are ALL around 250kb
most of them are arround 250kB and 8 of them are 1MB pngs.
well just for the sake of troubleshooting i would remove those 1mb images and see if it still happens
0

Did you manage Bitmap objects? If so, you have to call Bitmap.recycle() method.

Bitmap.recycle() API documentation

1 Comment

Yes I use Bitmap.recycle() in every possible place

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.