AnsweredAssumed Answered

arcgis javascript memory leak

Question asked by on Oct 11, 2018
Latest reply on Aug 12, 2020 by amurdoch22

I'm trying use client-side feature layer to display tweenty thounds polygon on map, i need add/remove layer frenquenly, i found when a add some layer then remove all of it, chrome memory usage only decrese a small part of it increase. 

there is some code of my app:

create map and mapview:

cosnt map = new Map({
  basemap: 'osm'
const mapView = new MapView({
  container: 'viewDiv',
  center: [xx, yy],
  zoom: 5

add layer:

const graphics =, (grid) => ({
  geometry: new Polygon({
    hasZ: false,
    hasM: false,
    rings: grid.ring

  attributes: {

const layer = new FeatureLayer({
  source: graphics,
  objectIdField: 'ObjectID',
  renderer: renderer,
  popupTemplate: pTemplate

clear layer:


I found if i not create MapView(only create Map, and add/remove layer on map) it works fine, does it means i miss call some method on MapView to clear?


============== Update =================

i debug use chrome dev tool memory snapshot, i found when i add then remove layer, there a some object left, e.g. 4.9/esri/layers/graphics/data/DefaultSpatialIndex.js file _.featuresById field, the clean method not called.