<?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: Dispose map related objects after use in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094644#M10400</link>
    <description>&lt;P&gt;When you say "&lt;SPAN&gt;the memory in the background keeps growing and is never released" did you run the memory analysis tool to determine which objects are holding on to it? It is possible something in your navigation backstack is still alive.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also note that the .NET Garbage Collector is pretty indeterministic wrt when it runs, so it might not actually be leaking, but GC just hasn't gotten around to collecting things. You could try running this code 3 times to be absolutely sure that everything that can be collected has been collected:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GC.Collect();&lt;BR /&gt;GC.WaitForPendingFinalizers();&lt;BR /&gt;&lt;BR /&gt;Just don't do that too often, as it is a blocking/expensive call, but it is useful to determine if something is actually still holding on or not.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Sep 2021 20:07:41 GMT</pubDate>
    <dc:creator>dotMorten_esri</dc:creator>
    <dc:date>2021-09-01T20:07:41Z</dc:date>
    <item>
      <title>Dispose map related objects after use</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1092689#M10382</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have a vtpk file on our device which we use to generate the map in offline mode.&lt;BR /&gt;Following is the code that we are using currently to do this. We found out that once the map is loaded the memory in the background keeps increasing and is never released.&lt;BR /&gt;In our Xamarin Forms UWP application, we use this map on the HomePage and few other following pages. As we navigate in the app, the memory in the background keeps growing and is never released.&lt;BR /&gt;&lt;BR /&gt;We investigated this further and think that the lines 6 and 8 where we load the tiled layer from file on device, the "tilecache" and "vectorTiledLayer" are never disposed from memory. We also looked up if we can use IDisposable interface to dispose objects but seems like these two objects don't implement this interface.&lt;BR /&gt;&lt;BR /&gt;What is the best and efficient way to load the offline vtpk file without affecting the memory much?&lt;BR /&gt;What we are doing below, is this the standard way of loading offline files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var mapPackageFolder = Constants.TpkFolderLocation;
var mapPackageFile = @"Tas_WebM_BaseMap_no_contour.vtpk";

var mapPackagePath = System.IO.Path.Combine(mapPackageFolder, mapPackageFile);

var tileCache = new VectorTileCache(mapPackagePath);

ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(tileCache);

map = new Map(new Basemap(vectorTiledLayer));

// Create starting viewpoint
Viewpoint startingViewpoint = new Viewpoint(
-42.882317, 147.327125,
10000);

map.InitialViewpoint = startingViewpoint;

return map;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 14:30:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1092689#M10382</guid>
      <dc:creator>KrishnaShinde</dc:creator>
      <dc:date>2021-08-26T14:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dispose map related objects after use</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094040#M10393</link>
      <description>&lt;P&gt;I am also facing this issue while loading ECWs in a scene.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 15:47:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094040#M10393</guid>
      <dc:creator>TasawarAhmad</dc:creator>
      <dc:date>2021-08-31T15:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dispose map related objects after use</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094260#M10394</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1052"&gt;@dotMorten_esri&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;Any thoughts on this.&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 05:51:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094260#M10394</guid>
      <dc:creator>KrishnaShinde</dc:creator>
      <dc:date>2021-09-01T05:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dispose map related objects after use</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094644#M10400</link>
      <description>&lt;P&gt;When you say "&lt;SPAN&gt;the memory in the background keeps growing and is never released" did you run the memory analysis tool to determine which objects are holding on to it? It is possible something in your navigation backstack is still alive.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also note that the .NET Garbage Collector is pretty indeterministic wrt when it runs, so it might not actually be leaking, but GC just hasn't gotten around to collecting things. You could try running this code 3 times to be absolutely sure that everything that can be collected has been collected:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GC.Collect();&lt;BR /&gt;GC.WaitForPendingFinalizers();&lt;BR /&gt;&lt;BR /&gt;Just don't do that too often, as it is a blocking/expensive call, but it is useful to determine if something is actually still holding on or not.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 20:07:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dispose-map-related-objects-after-use/m-p/1094644#M10400</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2021-09-01T20:07:41Z</dc:date>
    </item>
  </channel>
</rss>

