question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Possible memory leak with Map

See original GitHub issue

Mapbox Implementation

Mapbox

Mapbox Version

10.9.0

Platform

iOS

@rnmapbox/maps version

10.0.0-beta.54

Standalone component to reproduce

import MapboxGL from '@react-native-mapbox-gl/maps'
import * as React from 'react'
import { View } from 'react-native'
import { Footer } from '../components'

export default function MapStripped() {
  return (
    <View style={{ flex: 1 }}>
      <MapboxGL.MapView styleURL="mapbox://styles/mapbox/streets-v11" style={{ flex: 1 }} />
      <Footer />
    </View>
  )
}

Observed behavior and steps to reproduce

Note: Footer in example code is simply a tab bar to navigate between screens

The map is not cleaning up its memory usage when unmounted (like on a screen switch) and subsequent loads of the map screen adds to the memory consumption until eventually the app crashes for OOM. Our app is using react-navigation with a drawer navigator where the screens are unmounted on blur.

Here is the memory graph switching back and forth between the barebones map screen provided and our Home screen:

Screenshot 2022-10-31 at 4 49 57 PM

Here is the memory graph for the switching back and forth between the same Home screen and another one of our screens that has a lot of images on it. The initial spike at the beginning of the graph is the map screen.

Screenshot 2022-10-31 at 4 28 58 PM

Expected behavior

Map should properly clean up its memory consumption when unmounted

Notes / preliminary analysis

No response

Additional links and references

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mfazekascommented, Nov 1, 2022

@mysport12 thanks much for the report!

Using memory graph in Xcode ( image) and filtering for RCTMGLMapView it’s easy to see that it’s indeed a leak, caused by retain cycles. Added a fix for it in #2372

0reactions
mysport12commented, Nov 2, 2022

Noted. Happy to make any changes you propose

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug: huge memory leak [35823064] - Issue Tracker - Google
Run app with memory leak profiler. Open form with google map control and with selected marker. Just lock/unlock device and profiler shows that...
Read more >
Bug report #6795: Possible Memory Leak in Map Rendering
There is a potential memory leak with the map canvas when rendering raster images. With a single raster loaded (TIF) each change to/update...
Read more >
Memory leak with map - c++ - Stack Overflow
I can't clear the map memory (I checked by Valgrind). ... I tried _map.clear() , erase() , deleted _map->second manually but not still...
Read more >
Bug: Memory Leak when rendering arrays · Issue #20368
map stays alive in memory when the components are unmounted. The expected behavior. No components should stay in memory when they are unmounted....
Read more >
Bug: Occasional severe memory leak on token drop on map.
I can see the hand indicating that I'm holding the token and about to drop it, but it never drops onto the map....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found