Can't Delete .vtpk file after loading

4577
6
07-09-2019 11:31 AM
SamuelGrosenick
New Contributor

Hello, 

I'm working on basemap control in a Xamarin Forms app targeting UWP. I am using v100.4.0. The app has the ability to load any .vtpk's and .tpk's that are in the device's My Documents folder. I want the user to be able to remove any of these .vtpk or .tpk files from the app if they would like too.

I'm currently able to add/remove any .tpk's. I am also able to load and delete .vtpk's, but only as long as I don't turn that basemap on. It seems that once I load a vector tile layer, the file stays locked in memory. I have tried turning on a .vtpk and then switching to another basemap, but I still cannot delete the file. I am getting a System.IO.IOException saying "The process cannot access the file xxx.vtpk because it is being used by another process"

Again, I am able to load a .tpk file, turn it on and off, then delete it with no problem. It just gives me that error if I try to delete a .vtpk once I have turned it on.

Any ideas on how to remove the vector tile layer from memory once I have switched to another basemap? Thanks.

6 Replies
by Anonymous User
Not applicable

I have the same problem in the ArcGis Runtime SDK for .NET v100.6

KavitaPandey
New Contributor II

I am also facing the same issue. Did you get any solution for this?

dotMorten_esri
Esri Notable Contributor

Sometimes the garbage collector can get a little lazy on cleaning up. Try forcing a GC prior to deleting:
GC.Collect();
GC.WaitForPendingFinalizers();

KavitaPandey
New Contributor II

Thanks Morten I did that . Put above GC force deletion code above deleting the .vtpk file but it is still giving same error.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Make sure all references to the layer is completely out of scope (no live variables pointing to it directly or indirectly), or the GC has no effect.

0 Kudos
SamuelGrosenick
New Contributor

Hi Kavita, I haven't found a solution to this yet, unfortunately. 

0 Kudos