Android Question java.lang.OutOfMemoryError

Devv

Active Member
Licensed User
Longtime User
hi
i had made a program that loads about 200 items in a custom listview
in item 189 it crashes and give out of memory error

i had already used loadsample

B4X:
imv.Bitmap = LoadBitmapSample(File.DirInternalCache,AsyncDownloader.FileName,640,360)

my device is galaxy s6 edge, which is very powerfull, why did it crashed in less than 200 images ?

is there is a way to load the images only when i scroll to them ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
(It should be 640dip, 360dip)

You can ask the OS to give you more memory by adding this line to the manifest editor:
B4X:
SetApplicationAttribute(android:largeHeap, "true")

A better solution is to only load the images that are currently visible. Add more images when the user scrolls the list and remove non-visible images.
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
(It should be 640dip, 360dip)

You can ask the OS to give you more memory by adding this line to the manifest editor:
B4X:
SetApplicationAttribute(android:largeHeap, "true")

A better solution is to only load the images that are currently visible. Add more images when the user scrolls the list and remove non-visible images.

thanks for fast replay
1- what will b4a consider the size if i did not sepecify the dip or %x ?
2- how can i do the better solution ?
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
Hi Erel
how can i "only load the images that are currently visible" ?
 
Upvote 0
Top