Looks like I have too many items in a Map list and caused an out of memory error.
Currently I have no limit on the number of items I am putting in the map, which I think it is causing it to crash since the device got out of memory.
I am thinking of only adding a maximum of 1000 items in the map, and when it gets 1000 in the list remove the oldest item in the map..
B4X:
If Map.Size > 1000 Then
Dim lastitemKey As Int = Map.GetKeyAt(0)
Map.Remove(lastitemKey)
End If
Map.Put("item,"item")
However the question I have, what happens if 1000 is still too many? Is there a way to detect if it's reaching the devices memory limit and reduce the amount of items being added to the map ?
What's the best way in detecting the available memory before a crash happens?
Is there a way to detect the out of memory before it happens, so that I can display a message to the user that the app is about to crash due to the low memory available ?
1) are you using only that map or also a View to display map data?
2) can you test your app on an emulator of the user's device?
3) can the user device be defective?
4) can the user be a "disturber"?
5) can I avoid writing this kind of post? (probably not )
I agree, since I have tested this on a number of my own devices with any issue plus have a few guys in the office with Samsung devices and no one else has reported this issue before.
I guess it's just this one user and hopefully it's a one off issue. I will monitor it and see how it goes.
1) are you using only that map or also a View to display map data?
2) can you test your app on an emulator of the user's device?
3) can the user device be defective?
4) can the user be a "disturber"?
5) can I avoid writing this kind of post? (probably not )