Closed cbalster closed 7 years ago
sounds good. maybe we could also think about an object pool where we keep map markers for later use if they aren't needed anymore and should be kept from being garbage collected.
Thought about it too. But Markers are quite cheap and I don't think the user count varies a lot (correct me if I'm wrong). Therefore I expect a full-fledged object pool to be overkill. Will take a look at this the next days.
yea no you're right they don't vary too much. worst case in berlin we have ~800 users so there might be ~10 more or less with every server call.
okay, then I'll take care of that :)
I actually did some testing a while back and I didn't see any advantages in performance/memory churn by changing this - not worth the effort.
:+1:
I see two problems here: First of all osmdroids overlay list is backed by a CopyOnWriteArraylist which creates a new copy on every mutation. Secondly we are currently allocating new Objects for the markers on each refresh which is less then optimal (which is kinda my fault due to 9bfca7171d043e3da99f8e0d1016c012dd9ce34f ;) ). I would suggest keeping a local copy of the overlays as a normal Arraylist in MapFragment. Then we could update the existing ones and add and remove as needed on each refresh in that local list. When done we can just .clear() and .addAll() the osmdroid one. This would reduce the mutative operations to two in all cases. Thoughts?