-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix memory leak when removing map #13110
Fix memory leak when removing map #13110
Conversation
@stepankuzmin any followup on that/is something blocking this issue to be resolved? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, nice catch!
While we're still looking into this (most likely, it's fine for external contributors to edit that in PRs too), let us add a fix while we confirm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow response and thanks for the fix @kamil-sienkiewicz-asi!
@stepankuzmin Thanks for the merge, however I can still observe that map is not removed entirely. It's not piling up in memory, however If you could confirm that I can touch this code under TOS I can work on that in a meanwhile. |
@kamil-sienkiewicz-asi Hmm, that's weird, I've checked with your example from #9126 (comment) and haven't seen dangling Map instances. But sure, please go ahead and we'll review your PR 👍 |
@stepankuzmin #13116 as promised. |
Hey, so I digged a little in code to resolve this issue #9126 and it kinda seems like I found what the issue is (for a bare map, nothing was touched after mounting).
Tested it using
FinalizationRegistry
and heap snapshotsBefore:
When Map was added and removed using
map.remove()
it was piling up in memory heap snapshot.After my changes:
When Map is removed and another instance of map is being mounted, previous instance is garbage collected.
Which wasn't exactly what I wanted.
I suspect that another issue lies in:
src/ui/map.js
in
_authenticate
->getMapSessionAPI
->error callback
which holds
this.painter
forever asconst mapSessionAPI_ = new MapSessionAPI();
is created in global scope and never freed.but that code is just below warning about terms of service, so I'm not touching that :p
For future issues: Do I have permission to modify/debug this code with good intentions? All changes that improve mapbox would be put out in public PRs to approve by mapbox team.
@mourner @stepankuzmin let me know if that works and if you could handle issue in code that is under TOS 🤝