1

I am developing an application that includes image processing ( grayscale , Bw filte ,object detection ,color adjustment ,level adjustment ).

As you know, new mobile phones takes high quality images with large sizes.Due to memory limitations, it is difficult to image processing and outofmemoryException occurs frequently .So I've moved compeletely image proccessing from Java layer to JNI as follows:

  1. Mat file loaded in jni by source file path.
  2. Proccessing ....
  3. Result mat are stored in sd card.
  4. Result image loaded in inSampledSize bitmap as preview.

OutOfMemoryException does not occur with this method in image proccessing . but sometime when image have very large dimensions , Activity closed automattically during image processing without any exception and it's cause did not specify when debugging. Why is this happening? And How can I fix this?

Excuse me for my english.

1 Answers1

0

There are two things you could two :

First check if the problem happens while doing the image processing, if yes try to offload it from main thread and do it in a separate thread (may be an async task to start with). For more info on this refer this

Out of Memory Issue happens easily when you try set the high resolution images(bitmap) to the ImageView. If you are doing this you should lower the resolution before setting it to the ImageView. For more info on this please refer this link and also this stackoverflow post.

Community
  • 1
  • 1
Kingston
  • 474
  • 5
  • 14
  • thank you but I do image proccessing in async task,i said "Result image ( bitmap ) loaded in inSampledSize (scaled) bitmap as preview." so it is not high resolution bitmap. – nancy tyler Jul 10 '16 at 06:11
  • Try using this for time being android:largeHeap="true". If it works you might have to optimize your memory usage. – Kingston Jul 10 '16 at 11:03