Memory consumption using OfflineMapTask

540
3
02-12-2021 03:08 AM
ERICDUCOS
New Contributor II

Hi,

I have a piece of code in my Xamarin Forms apps that performs a test to know if a new Prepared Offline map is available. The code is a background task that run a loop and perform the query every X minutes...

Each time I am calling the  OfflineMapTask.CreateAsync to get the OfflineMapTask object, it consumes about 10 Mo memory and this memory is not released even when forcing Garbage Collection with GC.Collect()...There is no Dispose method...

And after a while, the apps breaks with an Out Of Memory error.

Can you tell me hao I can free the memory consumed by the OfflineMapTask.CreateAsync method ?

Regards.

Eric.

0 Kudos
3 Replies
KrishnaShinde
New Contributor II

Hi Eric
Did you manage to fix this issue?
If so, can you please share details?
We are stuck on this at the moment.

Thanks

0 Kudos
EricDUCOS1
New Contributor III

Hi,

Yes, I found a fix just by calling only one time the CreateAsync methode and keep the result object of type OfflineMapTask in cache. So each time I call the server, I reuse the same OfflineMapTask to query server if any OfflineMap is available.

I got an answer of ESRI technical team that they could not reproduce the problem...but it seem that I am not alone having such a problem !!

Regards.

0 Kudos
KrishnaShinde
New Contributor II

Thanks Eric.

We are working with an already existing map file on our device. We are using below code to load the map.
In doing so, I think the "tilecache" and "vectorTiledLayer" objects are not disposed from the memory. Do you know any other way of loading the offline maps?

 

 

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;

 

 

 

0 Kudos