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

Memory leak on map.remove() #4811

Open
elo58 opened this issue Oct 8, 2024 · 2 comments
Open

Memory leak on map.remove() #4811

elo58 opened this issue Oct 8, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers PR is more than welcomed Extra attention is needed

Comments

@elo58
Copy link

elo58 commented Oct 8, 2024

hello,

I have a website where several pages contain a maplibre map. It's a SPA so maplibre-gl.js is not unloaded/reloaded for each map. Maps are created and destroyed over the navigation.
I have issues with memory consumption which increase each time i create and then destroy a map.

My work is based on maplibre 4.1 but i have also tested with maplibre 4.7.1 and the issue is the same (may be a little better with 4.7.1)

maplibre-gl-js version: 4.7.1

browser: Chrome 128 / linux

Steps to Trigger Behavior

  1. map = new maplibregl.Map({ ... })
  2. map.remove()
  3. monitor memory consumption

Link to Demonstration

I have wrote a sample code to reproduce my problem :
https://output.jsbin.com/vumugiroma
Each time you press 'space' key you create or destroy a map.
The total used memory increase at each time (Check with Chrome task manager or memory in Devtools)

Expected Behavior

Don't increase memory consumption after several creation and destruction of maps.

Actual Behavior

Some objects are not released

@HarelM
Copy link
Collaborator

HarelM commented Oct 8, 2024

Thanks for taking the time to report this issue!
Feel free to investigate further and open a PR to fix this.
There is a lot of cleaning up code in map.remove method, but there might be places that were not handled properly.

@HarelM HarelM added bug Something isn't working good first issue Good for newcomers PR is more than welcomed Extra attention is needed labels Oct 8, 2024
@HarelM
Copy link
Collaborator

HarelM commented Oct 8, 2024

There's also this report, which has a root cause investigated already:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants