2

I'm using a ViewPager with 13 pages. It is managed using a FragmentStatePagerAdapter, and each page loads 250ko images as backgrounds, and sometimes 5 images more per page.

I get extremely often an OutOfMemoryError error and I'm testing my app on a Samsung Galaxy Tab 2, so I guess I'm doing something wrong.

Is there a way to release images which are not used on the life cycles of my Fragments on the ViewPager? Any other idea?

Thanks in advance.

thomaus
  • 6,170
  • 8
  • 45
  • 63
  • 1
    Did you increase `setOffscreenPageLimit(..)`? – DroidBender Jul 12 '12 at 07:16
  • have a look at this issue http://stackoverflow.com/questions/9373059/outofmemeoryerror-viewpager-imageviews http://stackoverflow.com/questions/9171857/android-how-to-avoid-the-out-of-memory-exception Best of luck Aamirkhan I. – Aamirkhan Jul 12 '12 at 07:35

2 Answers2

0

Everything is very well explained and detailed on Displaying Bitmaps in Your UI

thomaus
  • 6,170
  • 8
  • 45
  • 63
-1

Setting up the android:largeHeap to true is also extremely useful for this kind of problems.

thomaus
  • 6,170
  • 8
  • 45
  • 63