user2629279
user2629279

Reputation: 1

How to handle memory in galleryview in android?

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.

Upvotes: 0

Views: 72

Answers (4)

Exceptional
Exceptional

Reputation: 3004

Just use

system.gc();

Runtime.getRuntime().gc();

Upvotes: 0

KOTIOS
KOTIOS

Reputation: 11194

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

Upvotes: 1

canova
canova

Reputation: 3975

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

Upvotes: 1

Boris Mocialov
Boris Mocialov

Reputation: 3489

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

Upvotes: 0

Related Questions