react-native-maps: Multi-instance Memory Leak
On Android, when using react-native-maps with the react-native-router-flux router, when a map is loaded over and over, there is a large memory leak that can result in an application crash.
It appears that the map instance is not disposed of. After a short look at a heap dump, it seems like ‘AirMapView’ is not getting disposed. I suspect this is a native Java wrapper around the Google Maps instance.
It looks like the issue was introduced after 0.10.1, and exists in 0.11.0.
I’ve created a simple project to make this issue easy to reproduce.
https://github.com/gregberns/ReactNativeMapTest
I haven’t done much work with this project or RN’s native components, but I’ll try and dig in a little further and see where it can go, but any help to resolve this would be very welcome.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- issue#939, a temp fix for for airbnb#939 — committed to phantomlds/react-native-maps by mattshen 7 years ago
- issue#939, a temp fix for for airbnb#939 — committed to phantomlds/react-native-maps by mattshen 7 years ago
- Applying patch for #939 (https://github.com/airbnb/react-native-maps/issues/939) patch from: https://github.com/phantomlds/react-native-maps/commit/96db66311c9645bd68ce53604dec1fbe103981a3 — committed to tt-sport-mobile/react-native-maps by deleted user 7 years ago
Looks this was introduced by PR #694, made by @felipecsl , merged by @spikebrehm. Calls to
AirMapView.doDestroy()were removed to fix #414. Thats the only change I can see that seems like it could cause the extra map instances.