1

I am using ImageLoader and refering this link

I have used both methods DisplayImages() and getBitmap() but getting OutOfMemory error every time. From the developer site I have read and found that it can be solved by using RecycleImageView and RecycleBitmapDrawable classes.

No idea, how to implement this in adapter's getView() methd.

After using android:largeHeap="true" , The logcat displays...

02-27 13:21:00.846: D/OpenGLRenderer(12301): Enabling debug mode 0
02-27 13:21:03.379: D/dalvikvm(12301): GC_CONCURRENT freed 2273K, 18% free 12037K/14580K, paused 2ms+3ms, total 24ms
02-27 13:21:12.028: D/dalvikvm(12301): GC_FOR_ALLOC freed 339K, 14% free 12605K/14580K, paused 29ms, total 36ms
02-27 13:21:13.180: I/dalvikvm-heap(12301): Grow heap (frag case) to 152.441MB for 144636048-byte allocation
02-27 13:21:13.240: D/dalvikvm(12301): GC_CONCURRENT freed 4352K, 5% free 149498K/155828K, paused 14ms+5ms, total 61ms
02-27 13:21:16.003: D/dalvikvm(12301): GC_FOR_ALLOC freed <1K, 5% free 149498K/155828K, paused 17ms, total 18ms
02-27 13:21:16.003: I/dalvikvm-heap(12301): Forcing collection of SoftReferences for 325431088-byte allocation
02-27 13:21:16.043: D/dalvikvm(12301): GC_BEFORE_OOM freed 10K, 5% free 149488K/155828K, paused 37ms, total 37ms
02-27 13:21:16.043: E/dalvikvm-heap(12301): Out of memory on a 325431088-byte allocation.
02-27 13:21:16.043: I/dalvikvm(12301): "main" prio=5 tid=1 RUNNABLE
02-27 13:21:16.043: I/dalvikvm(12301):   | group="main" sCount=0 dsCount=0 obj=0x41f7cb50 self=0x41f6c1d0
02-27 13:21:16.043: I/dalvikvm(12301):   | sysTid=12301 nice=0 sched=0/0 cgrp=apps handle=1075268828
02-27 13:21:16.043: I/dalvikvm(12301):   | state=R schedstat=( 0 0 0 ) utm=296 stm=68 core=0
02-27 13:21:16.043: I/dalvikvm(12301):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
Rohit
  • 687
  • 5
  • 22
  • try using thumbnail, since ur image semms to be too huge – KOTIOS Feb 27 '14 at 07:13
  • Please Ref This Link Dude. http://stackoverflow.com/questions/22059479/out-of-memory-handle-in-android?noredirect=1#comment33449769_22059479 – saravanan Feb 27 '14 at 07:16
  • take a look at: http://stackoverflow.com/questions/21795645/exception-outofmemoryerror/21950787#21950787 and http://stackoverflow.com/questions/22043232/out-of-memory-exception-with-custom-gridview/22043466#22043466 – Pararth Feb 27 '14 at 07:16
  • @Monika yes.. i think.. u say correct? – saravanan Feb 27 '14 at 07:18
  • @Monika No, Images sizes are just 10kb - 20kb and I have already used decodeFile() method to reduce size to half but it's still not working. – Rohit Feb 27 '14 at 07:19
  • @Android Ref This link also.. this also helpful to you .http://stackoverflow.com/questions/16765899/out-of-memory-error-with-bitmap – saravanan Feb 27 '14 at 07:25
  • @saravanan Thanks, But I have already used it, didn't work for me... – Rohit Feb 27 '14 at 07:34
  • Try this link http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview – Arun PS Feb 27 '14 at 07:41
  • File size is not important. What resolution are the images and how many? `Out of memory on a 325431088-byte allocation` what are you loading that is trying to take 320MB of memory? – Simon Feb 27 '14 at 08:02
  • @Simon I don't know why?, This is the array of image url : **[http://www.offerpunch.com/uploads/deal/262_1.jpg, http://www.offerpunch.com/uploads/deal/229_1.jpg]** – Rohit Feb 27 '14 at 09:16
  • @Simon The second image size is just 13.91kb, width 252, height 166. – Rohit Feb 27 '14 at 09:23
  • That image on it's own will take 167kb when loaded (width x height x 4 bytes) unless you scale it. With an array, you could quickly run out of heap space. – Simon Feb 27 '14 at 23:58
  • @Simon Thanks for your support, I found my [solution](http://stackoverflow.com/questions/21979799/outofmemory-error-in-volley-library/22086617#22086617). – Rohit Feb 28 '14 at 05:13

1 Answers1

0

use android:largeHeap="true" in your manifest file in side application tag.

Yogendra
  • 4,817
  • 1
  • 28
  • 21