You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Load the example in Chrome on a Windows 10 device using a Nvidia GPU (GTX GeForce 660 series with latest drivers).
Move the mouse cursor repeatedly over features in the map using map.setFeatureState() on a vector tile source to change the hovered feature's style. Do not zoom or pan the map.
Each map.setFeatureState() call, the browser memory allocation increases. If you call setFeatureState() enough before zooming to new tiles, the browser crashes.
changed the title [-]Memory Lead calling map.setFeatureState() frequently [0.46-beta1][/-][+]Memory leak calling map.setFeatureState() frequently [0.46-beta1][/+]on Jun 20, 2018
@ryanbaumann Looking at that performance profile, the thing that solidly trends up is "Nodes", which I think is DOM nodes -- makes me suspect the actual problem is all the popups getting created. Can you remove the popup part of the code to see if you can still reproduce the leak?
I didn't have much luck reproducing on Chrome/Windows 10 running in VirtualBox, but I think it may just be so slow that I'm not patient enough to get the leak to show up...
Yup, looks like the popups were probably a red herring -- with that removed, the chrome profile doesn't show the "nodes" growth, but definitely looks like the same problem. Unfortunately the profile doesn't show much else going on -- JS heap usage looks like it ranges from 67-103 MB, which isn't anywhere near the several gigabyte growth for the process as a whole.
So... maybe something to do with re-uploading the the state-dependent paint vertex array to the GPU so frequently?
I think since these are supposed to be created as "dynamicDraw" buffers, so using updateData is more appropriate than destroying/recreating buffers. Updating the two upload()s in program_configuration to look more like:
Activity
[-]Memory Lead calling map.setFeatureState() frequently [0.46-beta1][/-][+]Memory leak calling map.setFeatureState() frequently [0.46-beta1][/+]ChrisLoer commentedon Jun 20, 2018
@ryanbaumann Looking at that performance profile, the thing that solidly trends up is "Nodes", which I think is DOM nodes -- makes me suspect the actual problem is all the popups getting created. Can you remove the popup part of the code to see if you can still reproduce the leak?
I didn't have much luck reproducing on Chrome/Windows 10 running in VirtualBox, but I think it may just be so slow that I'm not patient enough to get the leak to show up...
ryanbaumann commentedon Jun 20, 2018
@ChrisLoer I removed the DOM element creation on mousemove. I and am still able to re-created the issue.
Updated example without popup DOM element - https://bl.ocks.org/ryanbaumann/733ba99c5ca1d9d15259081b395e4b00/dee9a8fa1fec66ab5bbfe856aaa6604b1e70831c
Profile:
Chrome file
GIF of memory allocation in Windows 10 for Chrome :

ChrisLoer commentedon Jun 20, 2018
Yup, looks like the popups were probably a red herring -- with that removed, the chrome profile doesn't show the "nodes" growth, but definitely looks like the same problem. Unfortunately the profile doesn't show much else going on -- JS heap usage looks like it ranges from 67-103 MB, which isn't anywhere near the several gigabyte growth for the process as a whole.
So... maybe something to do with re-uploading the the state-dependent paint vertex array to the GPU so frequently?
cc @ansis
ChrisLoer commentedon Jun 20, 2018
This looks like the problem to me -- we re-upload when the paint arrays change, but if there's an existing vertex buffer we don't destroy it first:
mapbox-gl-js/src/data/program_configuration.js
Lines 186 to 190 in 20c0d13
I think since these are supposed to be created as "dynamicDraw" buffers, so using
updateDatais more appropriate than destroying/recreating buffers. Updating the twoupload()s inprogram_configurationto look more like:Seems to have fixed the problem, at least in @ryanbaumann's test case.
ansis commentedon Jun 22, 2018
@ChrisLoer yep! That's definitely what we need. And I'd guess this could have a pretty large performance benefit as well.
Use updateData instead of re-creating buffers for repopulated paint a…
Use updateData instead of re-creating buffers for repopulated paint a…
Use updateData instead of re-creating buffers for repopulated paint a…
ChrisLoer commentedon Jun 25, 2018
Fixed in #6853.