AnsweredAssumed Answered

Map CPU usage after destroy

Question asked by kriskaplan on Jun 25, 2018
Latest reply on Jun 28, 2018 by kriskaplan

When a map is displayed, it regularly uses CPU every second or two (timers triggering requestAnimationFrames).  In the Chrome task manager, a tab with a map view constantly bounces around 5% (from zero to ten).  Unfortunately, even if the window is not active.


But I would at least expect to be able to stop this CPU usage by destroying the MapView, and/or the Map.  But this does not seem to be the case.  Detaching the MapView from it's container and releasing the view and the map does not stop the CPU usage.  But perhaps I'm not stopping the map view properly (but I didn't notice any official documentation or sample about this).  I can reproduce this with a sample in the sandbox (e.g. intro-mapview) by adding the following attempt to cleanup code.

setTimeout(() => {
    view.container = null = null
    view = null
    map = null
}, 10000)

This seems related to this discussion and the suggestion is that removing the container reference and releasing the references is all it should take.  Removing the container reference from the view does do the majority of the detach of the canvas and surface from the dom, but there seems to be a reference keeping the timers firing and reacting.  How can we fully release the view?