• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OutOFMemoryError when handling images.

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application that I am working on works on images stored on SD card. When opening an image, I get OutOfMemoryErrors sporadically. Googling tells me that this is quite common with large bitmaps.

Are there any "guidelines" for handling large bitmaps - so as to avoid such errors?

Thanks.
 
Fred Grott
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you will want to degrade the image to reduce the file size:

if can involve
-adjusting color depth downward
-set higher image compression before saving image


 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fred!

Thanks for you reply..

I, eventually, did that(downgraded the image) and now I am having lesser problems. I am concerned about memory leaks in my code and about Dalvik's garbage collection though.

After I downgraded the image, if I keep changing from Portrait to landscape by pressing the '9' key on numpad, after 10-12 tries, the program runs out of memory. Perhaps, this has got something to do with GC?

Thanks.
 
Fred Grott
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you will get a GC operation on the views when changing orientations

Is there any way to use Canvas, bitmap, and paint and record the drawing of image one time use the recording?

That would be less memory intensive..



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic