<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492140#M45675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew (good name, by the way),&amp;nbsp; as a best practice I recommend creating an Angular service that lets you reuse/recycle MapViews and their associated DOM nodes, and that you also limit the number of MapViews. Each additional MapView initialized within your application will consume more memory up until you hit the browser limit for WebGL contexts (typically 16), or the browser tab might automatically restart because of high-memory usage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's no guarantee that your approach is actually deleting&amp;nbsp;"all" code references that are internal&amp;nbsp;and external to ArcGIS API for JavaScript modules, and therefore there are things that can't be garbage collected by the browser.&amp;nbsp;This issue isn't related to Angular specifically, it's just how JavaScript works.&amp;nbsp;I'm guessing from your code above&amp;nbsp;there's a really good chance the app&amp;nbsp;is creating&amp;nbsp;what's called&amp;nbsp;&lt;A href="https://developers.google.com/web/tools/chrome-devtools/memory-problems"&gt;detached DOM nodes&lt;/A&gt;, which is one type of major memory leak. they&amp;nbsp;can't be&amp;nbsp;garbage collected even if you try to null them out in your code.&amp;nbsp;You can see these detached nodes&amp;nbsp;when you do a JS Heap snapshot and search for the word "detached".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference:&amp;nbsp;&lt;A class="jivelink10" href="https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots" title="https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots"&gt;https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Aug 2020 18:38:03 GMT</pubDate>
    <dc:creator>AndyGup</dc:creator>
    <dc:date>2020-08-10T18:38:03Z</dc:date>
    <item>
      <title>Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492139#M45674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Day&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've noticed a memory issue where, at least in Angular 9, once your destroy the view / map objects, the memory usage is extremely high, ~100 MB / map.&amp;nbsp; I’ve Prepared a test repo, that initializes a map and allows you to jump to another page, when I run this code and jump between the pages the memory isn't being freed correctly, hopefully this helps:&lt;/P&gt;&lt;P style="border: none; padding: 0cm;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2Fdocmur%2Fangular-esri-memory-test" target="_blank"&gt;GitHub - docmur/angular-esri-memory-test&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My destroy functions, of our main application is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #ffc66d;"&gt;nullifyComponents&lt;/SPAN&gt;() {
  &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Destroying the ESRI View and ESRI Map'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  if &lt;/SPAN&gt;(&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;) {
    &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;removeAll&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;destroy&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    delete this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;} &lt;SPAN style="color: #cc7832;"&gt;else &lt;/SPAN&gt;{
    &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Map is NULL'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;}

  &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;) {
    &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;map &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;container &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;destroy&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    delete this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;} &lt;SPAN style="color: #cc7832;"&gt;else &lt;/SPAN&gt;{
    &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'View is NULL'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;}
&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_BasemapGallery&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;destroy&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_BasemapGallery &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;EsriMap &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;EsriMapView &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;FeatureLayer &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;SimpleMarkerSymbol &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;SimpleFillSymbol &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;SimpleLineSymbol &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;Color &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;Graphic &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;WatchUtil &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;BasemapGallery &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;Home &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;Expand &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;Print &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;PrintTask &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;PrintTemplate &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;PrintParameters &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_BasemapGallery &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;&lt;/SPAN&gt;
}

&lt;SPAN style="color: #ffc66d;"&gt;removeByTag&lt;/SPAN&gt;(tag) {
  &lt;SPAN style="color: #cc7832;"&gt;const &lt;/SPAN&gt;element = &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;document&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;getElementById&lt;/SPAN&gt;(tag)&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  while &lt;/SPAN&gt;(element[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]) {
    element[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;].&lt;SPAN style="color: #9876aa;"&gt;parentNode&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;removeChild&lt;/SPAN&gt;(element[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;])
  }
}

&lt;SPAN style="color: #808080;"&gt;@HostListener('window:beforeunload')
&lt;/SPAN&gt;&lt;SPAN style="color: #ffc66d;"&gt;async ngOnDestroy&lt;/SPAN&gt;() {
&lt;SPAN style="color: #cc7832;"&gt;  try &lt;/SPAN&gt;{
    &lt;SPAN style="color: #808080;"&gt;/* Get rid over everything else */
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;removeAll&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;/* Destroy and remove memory references to the maps */
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;nullifyComponents&lt;/SPAN&gt;()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;mapViewEl &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;null;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    delete this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;mapViewEl&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;removeByTag&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'mapElement'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;} &lt;SPAN style="color: #cc7832;"&gt;catch &lt;/SPAN&gt;(error) {
    &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(error)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;}
}&lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;When I look at the memory tab I see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/502875_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run a heap stack trace I see:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;IMG __jive_id="502849" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/502849_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Among another objects.&amp;nbsp; Is there another way to assure the memory is getting freed?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I navigate back to the maps and away, it will add another 100 MB / map, until all the memory is used up.&amp;nbsp; The function removeAll is setting all internal variables to null to assure they don't reference any of the ESRI components. &amp;nbsp;&amp;nbsp; The version of the library in use is 4.14. I’ve tried everything I can think of to free the memory including deleting the DOM elements in ngOnDestroy, and after they’re removed, the memory still remains.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've seen this across Windows, Linux and Firefox / Chromium based browsers.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:39:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492139#M45674</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2021-12-11T21:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492140#M45675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew (good name, by the way),&amp;nbsp; as a best practice I recommend creating an Angular service that lets you reuse/recycle MapViews and their associated DOM nodes, and that you also limit the number of MapViews. Each additional MapView initialized within your application will consume more memory up until you hit the browser limit for WebGL contexts (typically 16), or the browser tab might automatically restart because of high-memory usage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's no guarantee that your approach is actually deleting&amp;nbsp;"all" code references that are internal&amp;nbsp;and external to ArcGIS API for JavaScript modules, and therefore there are things that can't be garbage collected by the browser.&amp;nbsp;This issue isn't related to Angular specifically, it's just how JavaScript works.&amp;nbsp;I'm guessing from your code above&amp;nbsp;there's a really good chance the app&amp;nbsp;is creating&amp;nbsp;what's called&amp;nbsp;&lt;A href="https://developers.google.com/web/tools/chrome-devtools/memory-problems"&gt;detached DOM nodes&lt;/A&gt;, which is one type of major memory leak. they&amp;nbsp;can't be&amp;nbsp;garbage collected even if you try to null them out in your code.&amp;nbsp;You can see these detached nodes&amp;nbsp;when you do a JS Heap snapshot and search for the word "detached".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference:&amp;nbsp;&lt;A class="jivelink10" href="https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots" title="https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots"&gt;https://developers.google.com/web/tools/chrome-devtools/memory-problems#discover_detached_dom_tree_memory_leaks_with_heap_snapshots&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 18:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492140#M45675</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2020-08-10T18:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492141#M45676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the response, I'll take a look.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 18:41:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492141#M45676</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2020-08-10T18:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492142#M45677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Day&lt;BR /&gt;&lt;BR /&gt;Solid name &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;BR /&gt;&lt;BR /&gt;Do you have an example of how to use a service to maintain the same view across several maps?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote this function, which lives in a service (esri-service.ts), which is separate from the esri-map-controller.ts:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #ffc66d;"&gt;initMap&lt;/SPAN&gt;(mapContainer: ElementRef) {
  &lt;SPAN style="color: #cc7832;"&gt;return new &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;Promise&lt;/SPAN&gt;( (r&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;j) =&amp;gt; {
    loadModules([
      &lt;SPAN style="color: #6a8759;"&gt;'esri/Map'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;      &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'esri/views/MapView'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    &lt;/SPAN&gt;]).&lt;SPAN style="color: #ffc66d;"&gt;then&lt;/SPAN&gt;(([
      EsriMap&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;      &lt;/SPAN&gt;EsriMapView&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;    &lt;/SPAN&gt;]) =&amp;gt; {

      &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map &lt;/SPAN&gt;=== &lt;SPAN style="color: #cc7832;"&gt;null &lt;/SPAN&gt;&amp;amp;&amp;amp; &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view &lt;/SPAN&gt;=== &lt;SPAN style="color: #cc7832;"&gt;null&lt;/SPAN&gt;) {
        &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\n\n&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;Allocating new Map!!!&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\n\n&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        const &lt;/SPAN&gt;mapProperties: esri.MapProperties = {
          &lt;SPAN style="color: #9876aa;"&gt;basemap&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_basemap&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        &lt;/SPAN&gt;}&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;EsriMap(mapProperties)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        const &lt;/SPAN&gt;mapViewProperties: esri.MapViewProperties = {
          &lt;SPAN style="color: #9876aa;"&gt;container&lt;/SPAN&gt;: mapContainer.&lt;SPAN style="color: #9876aa;"&gt;nativeElement&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;center&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_center&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;zoom&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_zoom&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;map&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map
&lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;        &lt;/SPAN&gt;}&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;EsriMapView(mapViewProperties)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        &lt;/SPAN&gt;r({
          &lt;SPAN style="color: #9876aa;"&gt;map&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;view&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view
&lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;        &lt;/SPAN&gt;})&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;      &lt;/SPAN&gt;} &lt;SPAN style="color: #cc7832;"&gt;else &lt;/SPAN&gt;{
        &lt;SPAN style="color: #9876aa; font-weight: bold; font-style: italic;"&gt;console&lt;/SPAN&gt;.&lt;SPAN style="color: #ffc66d;"&gt;log&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\n\n&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;Using Existing!!!&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\n\n&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        const &lt;/SPAN&gt;reAllocateMap = &lt;SPAN style="color: #cc7832;"&gt;false;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        if &lt;/SPAN&gt;(reAllocateMap) {
          &lt;SPAN style="color: #cc7832;"&gt;const &lt;/SPAN&gt;mapProperties: esri.MapProperties = {
            &lt;SPAN style="color: #9876aa;"&gt;basemap&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_basemap&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;}&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;EsriMap(mapProperties)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;map &lt;/SPAN&gt;= &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        &lt;/SPAN&gt;}

        &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;container &lt;/SPAN&gt;= mapContainer.&lt;SPAN style="color: #9876aa;"&gt;nativeElement&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;        &lt;/SPAN&gt;r({
          &lt;SPAN style="color: #9876aa;"&gt;map&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_map&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;          &lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;view&lt;/SPAN&gt;: &lt;SPAN style="color: #cc7832;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;_view
&lt;/SPAN&gt;&lt;SPAN style="color: #9876aa;"&gt;        &lt;/SPAN&gt;})&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;      &lt;/SPAN&gt;}
    })&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;})
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first time I call this I get a map and view and everything works fine, but when I call it a second time to get the view, then swap the ElementRef, the map appears but I can't interact with it.&amp;nbsp; If I change the code and allocate a new map object then assign it into the view, I get a fully interactive view and map back, but the memory usage goes way up again, which is the problem I'm trying to work around.&lt;BR /&gt;&lt;BR /&gt;When I look at the detached memory, I see a bunch of references to MapView.js and engine.js from an arcgis 4.15 / 4.14 url, which I think is coming from EsriMapView and EsriMap, but I can't do anything with them except set them to null in the ngOnDestroy, because if I try to call .destroy() an exception is thrown that the function doesn't exist.&lt;BR /&gt;&lt;BR /&gt;Could there be an issue with EsriMapView getting properly destroyed?&amp;nbsp; If you reference the sample project I made, it has this same issue, and I noticed the same problem on the angular-cli-map project.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:39:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492142#M45677</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2021-12-11T21:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492143#M45678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know of any&amp;nbsp;Angular examples. However, here is a simple codepen&amp;nbsp;that demonstrates&amp;nbsp;the basic concepts behind swapping MapViews:&amp;nbsp;&lt;A class="link-titled" href="https://codepen.io/andygup/pen/VwYjGRM" title="https://codepen.io/andygup/pen/VwYjGRM"&gt;https://codepen.io/andygup/pen/VwYjGRM&lt;/A&gt;. You'll need to apply similar concepts in your app.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2020 18:49:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492143#M45678</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2020-08-13T18:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492144#M45679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Afternoon&lt;BR /&gt;&lt;BR /&gt;I'll give this a try and let you know how it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2020 18:53:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492144#M45679</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2020-08-13T18:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492145#M45680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Found a good enough workaround,&amp;nbsp; if you call window.location.reload() inside ngOnDestroy of any page that hosts the maps, the memory will be freed, which is what we're doing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2020 16:57:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492145#M45680</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2020-08-26T16:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Issue - ArcGIS 4.14 &amp; Angular - Memory not getting freed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492146#M45681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gotcha,&amp;nbsp;full page refresh would definitely free the memory up however I'm sure that's not your preferred approach. So, some good news is we just added a view.destroy() method in the /next build of the JS API that you can test it out before the next release (4.17 - Early October 2020):&amp;nbsp;&lt;A href="https://github.com/Esri/feedback-js-api-next" rel="nofollow noopener noreferrer" target="_blank"&gt;https://github.com/Esri/feedback-js-api-next&lt;/A&gt;. If you have a chance to test it, let us know how if you run into any issues?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// Unset map from the view so that it is not destroyed&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;const&lt;/SPAN&gt; map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Coming in 4.17 - destroy the view and all attached resources&lt;/SPAN&gt;
view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;destroy&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:39:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/memory-issue-arcgis-4-14-angular-memory-not/m-p/492146#M45681</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2021-12-11T21:39:27Z</dc:date>
    </item>
  </channel>
</rss>

