简体   繁体   中英

How to dispose of a GMap instance

I have a program that use GMap. The GMap is in instance X(to give exemple). Instance X is called after a login. I can logout of X and start again the login process. The problem is that instance X never get released. I really thing that I have pinpointed the problem to the GMap, because right now I remove everything else that it loaded.

I tried to do this when I logout:

gmap.Manager.CancelTileCaching();
gmap.Dispose();
gmap = null;

I also remove the control itself from the xaml code with a

grid.Children.Remove(myMap)

Ok, Dispose does not mean, that object is removed from memory. Dispose method just releases unmanaged resources.

.NET has managed memory. And Grbage Collector (GC), that clears memory from unused objects.

You can force GC by using method GC.Collect() . But you sholdn't do it in real application. Let GC do it in the most suitable moment.

You can learn more from this video .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM