0

In my application i have two gallery views. whenever in my gallery images increases I am getting outofmemory exception.How i can handle the memory.please can any one help me?

Thanking in Advance.

4 Answers4

1

I would suggest you to first create a thubnails of images.

Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath), THUMBSIZE, THUMBSIZE);

Use lazy loading concept

here is the code of lazy loading that worked great for me

KOTIOS
  • 11,177
  • 3
  • 39
  • 66
1

Like Stacks28 suggested, use lazy loading concept. Additional to this, always do recycle() to your images and if you are still having troubles, add this in your manifest inside application tag : android:largeHeap="true"

here is an image loader example

canova
  • 3,965
  • 2
  • 22
  • 39
0

i believe that you have many bitmaps that you are doing lots of operations with loading them in memory and not freeing the memory

http://developer.android.com/training/displaying-bitmaps/manage-memory.html

Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55
0

Just use

system.gc();

Runtime.getRuntime().gc();
Exceptional
  • 2,994
  • 1
  • 18
  • 25