Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Huge memory leak in using QueryShape? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi all, Each time I call the below VB.NET code the memory usage of MapPoint increases up to 1-2mb. This ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Huge memory leak in using QueryShape? Each time I call the below VB.NET code the memory usage of MapPoint increases up to 1-2mb. This continues to increase until around 90-100mb when the application dies. The only way I have been able to prevent this is to completely create and destroy the mappoint object for every time I want to perform a region check on a location check (very slow obviously). The best solution would be to keep the mappoint application persistent (with map/shapes loaded) and then do a location check. Has anyone else had this issue or found a solution to the memory problem? Thanks! oLocation = oMap.FindAddress(Street, City, State, Zip, MapPoint.GeoCountry.geoCountryUnitedStates) If Not oLocation Is Nothing Then oPushpin = oMap.AddPushpin(oLocation, "Home") For Each mShape In oMap.Shapes If mShape.Type < MapPoint.GeoShapeType.geoLine Then For Each mData In oMap.DataSets mRst = mData.QueryShape(mShape) mRst.MoveFirst() Do While mRst.EOF = False If mRst.Location.StreetAddress.Value = oLocation.StreetAddress.Value Then Console.WriteLine("Senate District: " & mShape.Name) If sDistrict = "" Or sDistrict = "SD1" Then sDistrict = mShape.Name End If Exit For End If mRst.MoveNext() Threading.Thread.Sleep(1) Loop mRst = Nothing mData = Nothing Next mData End If Next mShape oPushpin.Delete() oPushpin = Nothing oLocation = Nothing End If oMap.Saved = True GC.Collect() Return sDistrict |
| |||
| And finally...
Well it turns out that to properly dispose of COM objects in .NET you cannot simply use the = Nothing statement. You must first use ReleaseComObject(oObject) and then set the object to nothing. An article is at http://support.microsoft.com/default...;EN-US;Q317109. So now you know ;-) P.S. Been real nice talking to myself on this forum ;-) |
![]() |
| Tags |
| huge, leak, memory, queryshape |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Memory leak - Bulk calculates | bigderek | MapPoint 2006/2009 Discussion | 7 | 10-08-2008 06:50 AM |
| Huge Number of Drive Times | lbequis | MapPoint 2006/2009 Discussion | 3 | 08-27-2005 08:31 AM |
| Problem with dataset.QueryShape Method | Ray Liu | MapPoint 2006/2009 Discussion | 1 | 07-15-2004 10:55 AM |
| memory leak with objloc.goto? | mzupan | MapPoint 2006/2009 Discussion | 1 | 08-02-2003 12:14 AM |
| QueryShape problem Please help | Anonymous | MapPoint 2006/2009 Discussion | 2 | 03-13-2003 08:57 AM |
Costa Brava Holiday
Beautiful kilometres of sandy beaches await you should you choose a Costa Brava holiday through UlookUbook!