OK this is a very common problem but mine is a bit different and I can’t find solution on other topics, so I post new one here. I have an application which show a ListView. Each row of ListView, I have an ImageView to load a small bitmap icon from SD card using ListAdapter (it’s small so the problem is not about the size). Now if I scroll the list slowly, it works fine. But if I scroll really fast, when the ListView is long enough, it’s not showing the icon anymore and messages in logcat is something like this:
126 600-byte external allocation too large for this process.
VM will not let us allocate 126,600 bytes
Then the app crash and logcat showed:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
I tested on 2 different devices and only 1 of them get this error, the other works normally.
Please notice that this error only occurred when the ListView is scrolled very fast. Is that because new threads created is not matched with the pace of garbage collection or something?
Can anybody give me some suggestion in this situation?
While working with bitmap you will mostly get OutOfMemory when used with ListView.
So you should go for LasyList as show here.
Will will take care of your image loading.
To work with SDCard you need to replace a method in ImageLoader Class as shown below