This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

OutOFMemoryError when handling images.

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



 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic