• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOFMemoryError when handling images.

 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic