I have a hard time understanding how B4A handles DIM's and memory management.
When I do this:
The same variable S is overwritten - the old S disappears from memory and gets a new value. No memory leak.
However, when I do this:
The S is still overwitten but a "copy" still stays in memory somewhere, otherwise the label wouldn't be visible. In order to regain the memory, I have to loop over the labels and remove them with removeView.
Is there a kind of list or tutorial available on the things we have to clean up ourselves in code to prevent these memory leaks?
When I do this:
B4X:
for t = 1 to 100
dim s as string = "My String"
next
However, when I do this:
B4X:
for t = 1 to 100
dim s as label= "My String"
Activity.addview(S,0,0,100dip,100dip)
next
The S is still overwitten but a "copy" still stays in memory somewhere, otherwise the label wouldn't be visible. In order to regain the memory, I have to loop over the labels and remove them with removeView.
Is there a kind of list or tutorial available on the things we have to clean up ourselves in code to prevent these memory leaks?