Map CPU usage after destroy

524
2
06-25-2018 12:09 PM
KrisKaplan1
New Contributor II

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
    view.map = 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?

Kris

Tags (2)
0 Kudos
2 Replies
ChrisSmith7
Frequent Contributor

Kris,

Have you seen this thread? How to remove the 2d map from the dom 

There was a bug with mapview at one point, which should have been fixed, per Esri discussions. Is it possible there are still issues with destroying completely?

0 Kudos
KrisKaplan1
New Contributor II

Chris,

Yes.  I referenced that discussion in my post with "This seems related to this discussion...".  There definitely does appear to still be issue (or regession) with the map destroying.  I was hoping to find some way to force it.

Kris

0 Kudos