Marker share icon image#2741
Merged
christopherdro merged 2 commits intoreact-native-maps:masterfrom Apr 12, 2019
Merged
Conversation
2ccd152 to
cdd9864
Compare
Collaborator
|
@zupaox that's awesome ❤️ LGTM @alveig @christopherdro 🐽 |
Contributor
Author
hey @rborn, I think iOS will use cached UIImage (loadImageWithURLRequest, RCImageCache), so it will not have the issue. We don't have iOS app crash reports because of memory issue as well. |
Use a shared image icon for markers instead of loading and creating bitmap for each marker, which uses more memory in case when we have a lot of markers but only use a limited set of images.
2bd8713 to
50e2812
Compare
Collaborator
christopherdro
approved these changes
Apr 12, 2019
pinpong
pushed a commit
to pinpong/react-native-maps
that referenced
this pull request
Feb 28, 2025
* Add a test example to add massive number of markers on map * Share image for markers to reduce memory usage Use a shared image icon for markers instead of loading and creating bitmap for each marker, which uses more memory in case when we have a lot of markers but only use a limited set of images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Does any other open PR do the same thing?
Looks No.
What issue is this PR fixing?
Android app's memory usage climbs high when there are thousands of markers on the map, even though most of the markers uses same image and the images are only around 1KB.
This update is to use a shared image icon for markers when they share the same image URI, instead of loading and creating bitmap within each marker, which uses more memory in case we have a lot of them.
How did you test this PR?
Ideally you should test it with an app that contains a lot of custom markers that shared a small image pool.
To make it simple, we have also created a new page in example app, named "MassiveCustomMarker", which will place 100 custom markers on tap on the map. You can check it out and run the example app. Open android studio profile and watch the memory usage before and after the update while placing more markers on the map.
As a reference, following is the memory profile before the update, tested on Samsung J2 (Samsung SM-G532G). The app crashed on about 500 markers:

Following is the memory profile after the update, Java memory consumption alomost remains constant regardless of the number of markers added. App does not crash even after 1000 markers.