Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker share icon image #2741

Merged

Conversation

zupaox
Copy link
Contributor

@zupaox zupaox commented Mar 14, 2019

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:
image

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.

image

@zupaox zupaox force-pushed the marker-share-icon-image branch 2 times, most recently from 2ccd152 to cdd9864 Compare March 14, 2019 07:49
@rborn
Copy link
Collaborator

rborn commented Mar 14, 2019

@zupaox that's awesome ❤️
Do we have the same issue on ios?

LGTM @alveig @christopherdro 🐽

@zupaox
Copy link
Contributor Author

zupaox commented Mar 14, 2019

@zupaox that's awesome ❤️
Do we have the same issue on ios?

LGTM @alveig @christopherdro 🐽

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.
I just did a test on simulator, it uses 700MB memory for 10K markers and is quite stable, so should not be an issue.

@rborn rborn requested a review from alvelig March 15, 2019 22:30
zupaox added 2 commits April 10, 2019 12:47
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.
@zupaox zupaox force-pushed the marker-share-icon-image branch from 2bd8713 to 50e2812 Compare April 10, 2019 04:48
@rborn
Copy link
Collaborator

rborn commented Apr 11, 2019

@alvelig @christopherdro 🐽

@christopherdro christopherdro merged commit 723db2c into react-native-maps:master Apr 12, 2019
@zupaox zupaox deleted the marker-share-icon-image branch February 3, 2020 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants