I have been getting Out of Memory Exceptions, which I am pretty certain are due to my using a large bitmap. I am creating this bitmap by drawing on the canvas cvs.
My first solution I found on this forum. I put this code in my Activity_Pause routine:
This helped to reduce the occurrence of the error, but I realized that I was redrawing my canvas many times between each call of Activity_Pause, and was probably creating many bitmaps in the process, and so decided to recycle the bitmap before each redrawing. But when I initialized the canvas following the recycle code above, I would get the error "Trying to use a recycled bitmap".
So I set the canvas to null after every recycle, so that a new bitmap would have to be recreated.
But this gave me an Java Null Exception error when I tried to reinitialize the canvas.
I am pretty new to b4a, and I thought that initialize would create a new object under any circumstances, either immediately after the dim or at any time later, but I am obviously missing something basic, since I wrote the following code which highlights my problem.
Help from the experts, please!
Ron
My first solution I found on this forum. I put this code in my Activity_Pause routine:
B4X:
Obj1.Target = cvs
Obj1.Target = Obj1.GetField("bw")
Obj1.Target = Obj1.RunMethod("getObject")
Obj1.RunMethod("recycle")
So I set the canvas to null after every recycle, so that a new bitmap would have to be recreated.
B4X:
Obj1.Target = cvs
Obj1.Target = Obj1.GetField("bw")
Obj1.Target = Obj1.RunMethod("getObject")
Obj1.RunMethod("recycle")
cvs = null
I am pretty new to b4a, and I thought that initialize would create a new object under any circumstances, either immediately after the dim or at any time later, but I am obviously missing something basic, since I wrote the following code which highlights my problem.
B4X:
cvs.Initialize(ivB) ' OK
cvs = Null
cvs.Initialize(ivB) ' Java Null Exception
Help from the experts, please!
Ron