GMapControl not being garbage collected

Nov 15, 2009 at 8:14 AM

I am trying to use this control in a WPF application.  I have the map in a popup window which can be opened and closed adn each time it is opened a new instance of the window is created.  What I have seen is that the Window never gets garbage collected.

I did a small test project where the main form has a button which only opens and closes a window with a GMapControl on and explicitly did a GC.Collect() behind another button and from and with my limited knowledge of WinDbg/SOS I could see that the window and the GMapControl objects were still left around after closing the window.  I tried to figure out what was keeping the objects alive but I am not skilled enuf with WinDbg/SOS to figure it out.

Any idea what the problem is?

Coordinator
Nov 15, 2009 at 2:27 PM

do you try to put another control there instead map?

Nov 15, 2009 at 2:40 PM

Yes, it is only when I have the map this happens.  I have looked into it a bit more and from my understanding it is the BackgroundWorkers in the Core class which are keeping the GMapControl and in turn the Window from being garbage collected.

Coordinator
Nov 15, 2009 at 4:35 PM

..try new version, it works now, but not quite instantly

Nov 16, 2009 at 7:01 AM

It solved some of the problems but not all, I will need to look into the remaining issues and see if I can reproduce them with a smaller sample.

Nov 16, 2009 at 12:51 PM

Maybe the IDisposable Pattern could solve this problem.

Look at this link for further information: click