0

I am developing an image processing app in which I have an album folder which contains more than one image.

Also there can be more than one album in project. On starting the application there is a list of albums. On selecting album gallarey view with images contained in that album are displayed.

If we select any image than new activity is launched in which you can do drawing over the selected image(i.e. you can draw lines or shapes over image). You can also add image to album, using camera or from gallery. Now the problem i am facing is that app works fine.But i am unable handle OutOfMemory error. I have tried lots of things. Such as

  1. Resizing image.
  2. Destroying activity.
  3. Using application context for database helper classes.
keyser
  • 18,829
  • 16
  • 59
  • 101

2 Answers2

0

You have to options to work with images in android: - using java and SDK - using native code and NDK

If you want to use only SDK try to use inSampleSize for sampling resource image. In addition to sampling image ensure that you properly recycle image resources after using and you haven't memory leaks in your app. You can use MAT to discover memory leaks.

Or you can write your code using NDK. When you using native code, objects which you create in it locates in native heap in contrast to java.

Dmitriy Tarasov
  • 1,949
  • 20
  • 37
0

The OOM(OutOfMemory) problem is always due to inappropriate processing about Bitmap Object. So what you have tried (resizing, destroy activity, ...etc) could not solve the OOM problem.

Better way to solve OOM is that Loading images into memory according to the resolution density of device. There is one chapter from Goole Android training course talking about How to Load large images efficiently. It can be referred here

https://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Hope this would help you!

A-Shi
  • 31
  • 3