[Bug]: Memory Leak Issue
Mapbox Implementation
Mapbox
Mapbox Version
default
Platform
iOS, Android
@rnmapbox/maps version
#main
Standalone component to reproduce
import React from 'react';
import {
MapView,
ShapeSource,
LineLayer,
Camera,
} from '@rnmapbox/maps';
const aLine = {
type: 'LineString',
coordinates: [
[-74.00597, 40.71427],
[-74.00697, 40.71527],
],
};
class BugReportExample extends React.Component {
render() {
return (
<MapView style={{flex: 1}}>
<Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
<ShapeSource id="idStreetLayer" shape={aLine}>
<LineLayer id="idStreetLayer" />
</ShapeSource>
</MapView>
);
}
}
Observed behavior and steps to reproduce
When navigating to a screen with a map and then navigating back or to another screen, the map does not unload properly. Every time we're loading a screen with a map in it, the memory adds up until it causes a memory exhaustion crash. This occurs both on iOS and on Android.
Expected behavior
No response
Notes / preliminary analysis
No response
Additional links and references
No response
Same issue on my project
I also have this issue.
@KristofferEriksson I've tried on current master, one with 10.11 as mapbox dependency. And It was working me just fine. I've replace BugReportExample.js with the code you've pasted bellow and then opened closed the BugReportTemplate example.

I'm closing this as I cannot reproduce. Please try with latest version and please describe how to reproduce in our example app.
@mfazekas @KristofferEriksson
This is still an issue on Android. Attached is a graph of how the memory use climbs when mounting and unmounting the BugReportExample screen 18 times. I made sure to signal a GC before stopping the recording, as you can see along the bottom.

I'm using 10.0.0-beta.76 with the default mapbox version.
@bradstiff added a fix for that - #2707
Beautiful. Looking forward to the release!
On Thu, Mar 16, 2023, 12:22 AM Miklós Fazekas @.***> wrote:
@bradstiff https://github.com/bradstiff added a fix for that - #2707 https://github.com/rnmapbox/maps/pull/2707
— Reply to this email directly, view it on GitHub https://github.com/rnmapbox/maps/issues/2591#issuecomment-1471387855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDU6IMCJ32XCO3JPPNDK3DW4KWS7ANCNFSM6AAAAAAUVBHQI4 . You are receiving this because you were mentioned.Message ID: @.***>