Android Question Out of memory: lots of canvas objects

wimpie3

Well-Known Member
Licensed User
Longtime User
I'm adding lots of bitmaps to one single page, and I'm running into an out of memory error. After searching through the forum, it seems that this could be due to too many canvas init's.

This is how I add my graphics:

B4X:
(loop start)
Dim ico1 As Label
ico1.Initialize("")
dim canvas1 As Canvas
Dim rect1 As Rect
canvas1.Initialize(ico1)
myicon.DrawPicture(canvas1, rect1)
(loop end)

How can I re-write this code?
 

kanaida

Active Member
Licensed User
Longtime User
try declaring your canvas before the loop once.
I'd also try just drawing all the stuff to a panel if it's just images and stuff.
It's like you're making a painting, but setting up the easel each time you want to draw a bush.
 
Upvote 0
Top