Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

Memory leak - Bulk calculates

This is a discussion on Memory leak - Bulk calculates within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello everyone - I've got some VB.Net code using the MapPoint 11.0 COM Objects that are doing bulk calculations of ...

  1. #1
    bigderek is offline Junior Member White Belt
    Join Date
    Nov 2004
    Posts
    4

    Memory leak - Bulk calculates

    Hello everyone -

    I've got some VB.Net code using the MapPoint 11.0 COM Objects that are doing bulk calculations of distances between two points.

    Here is the basic workflow:
    Code:
            m_oApp.PaneState = geoPaneRoutePlanner
    
            ' Ensure we're working in miles
            m_oApp.Units = GeoUnits.geoMiles
    
            m_oMap = GetObject(, "MapPoint.Application").ActiveMap
            m_oMap.Parent.PaneState = geoPaneRoutePlanner
    
            m_oRoute = m_oMap.ActiveRoute
            m_oRoute.Clear()
    
            ' Iterate through each row in the data row collection - a row represents an address in the route
            For Each dr As DataRow In dsRoutePoints
    
                Dim oLocation As MapPoint.Location
                Dim oFindResults As MapPoint.FindResults
    
                oFindResults = m_oMap.FindAddressResults(dr.Item("address").ToString, dr.Item("city").ToString, , _
                                                 dr.Item("state").ToString, CStr(dr.Item("zipcode")), "United States")
    
                If oFindResults.ResultsQuality = GeoFindResultsQuality.geoFirstResultGood Then
                    ' The first address seems to be valid - add the waypoint
                    oLocation = oFindResults(1)
                    m_oRoute.Waypoints.Add(oLocation)
    
                Else
    
    		 ...
    
                End If
    
            Next
    
            Try
                ' Calculate the route
                m_oRoute.Calculate()
    
            Catch ex As Exception
    
                ' Only one waypoint in the row collection - cannot calculate a route
                m_oMap.Saved = True
                m_oMap = Nothing
    
                ReturnResults.ErrorCode = MapPointStructs.CalculateRouteErrors.OnlyOneWaypoint
    
                Return ReturnResults
                Exit Function
    
            End Try
    
            m_oMap.Saved = True
    
            ' No errors occurred - distance calcualted. Return the results
            ReturnResults.ErrorCode = MapPointStructs.CalculateRouteErrors.NoErrors
            ReturnResults.DistanceCalculated = m_oRoute.Distance.ToString
    
            m_oRoute.Clear()
            m_oRoute = Nothing
    
            Return ReturnResults
    What I have found, however is that the MapPoint.exe in the Task Manager is consistantly going up, and up in memory useage. As you can see I am trying to set the Map Object to nothing - but it doesnt seem to be solving the problem.

    Any ideas?

    Derek

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Also try resetting the other objects when you finish with them - eg. the location and result objects.

    I assume the memory size keeps growing as it does the processing? If so, setting the map object to nothing after the processing won't have any effect unti it isl finished.

    MapPoint also seems to have a lazy garbage collector, and appears to grow to fill the space available when used on a large batch processing job. If you clear your objects correctly, this should tidy itself up when it closes.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    bigderek is offline Junior Member White Belt
    Join Date
    Nov 2004
    Posts
    4
    I tried setting the Map object to nothing on each loop - and it doesnt seem to be doing anything (as well as the Location, and Find Results objects).

    Also - when the process is finished, MapPoint does not release the memory - it still keeps a good 120 meg to itself. Subsequent iterations of the same batch process do not cause the memory to go any higher...however it does not drop at any time as well.

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Setting the Map to Nothing probably doesn't gain anything unless you leave it to the end.

    Does MapPoint stay dormant in memory, even when it is closed down? If so, you have a leaky COM object.

    When you program finishes, MapPoint will stay big. There are various valid reasons why this might be the case. It has 'taken' memory from the OS to meet requirements, but the bits that are still being used are probably spread throughout this large allocation (or it doesn't know any better).
    Maybe this is something for a future version - MapPoint should have a garbage collector that can "shrink" the full memory footprint, and can be called programmatically. It would be slow, but could be called at the end of a load of batch processing.

    You may also observe that MapPoint slows down as the memory footprint grows... (again, I think memory is the issue)


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    bigderek is offline Junior Member White Belt
    Join Date
    Nov 2004
    Posts
    4
    When I destroy the mappoint application object and close the application - all of the memory is released.

    I think what I'm going to do is force quit the mappoint application every X batches to release the large memory footprint; then re-open the application object.

  6. #6
    Geekodude is offline Junior Member White Belt
    Join Date
    Sep 2006
    Posts
    1

    Mappoint 2006 Memory Increases

    I see a similar pattern using the FindResults method. Mappoint increases in memory after repeated calls to that method even though I explicitly close the reference to it. I guess the solution with Mappoint 2006 is to force quit the mappoint application every X minutes to release the large memory footprint; then re-open the application object. This really blows. How would one report this to MS?

  7. #7
    sairampc is offline Junior Member White Belt
    Join Date
    Oct 2008
    Posts
    2

    Re: Memory leak - Bulk calculates

    MapPoint 2009 arrived but the old problem persists. Can anyone suggest a way to release the memory?

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Memory leak - Bulk calculates

    Hi,

    you can destroy the mappoint object once a while. for example when it is not needed for a while in your application. Generally this is a good programming technique.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Deleting pushpins in bulk
    By brianmcg in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-22-2006, 02:08 PM
  2. Handling Route that Calculates but does not Optimize
    By Eric Frost in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 03-07-2005, 03:07 PM
  3. memory leak with objloc.goto?
    By mzupan in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-02-2003, 01:14 AM
  4. Huge memory leak in using QueryShape?
    By random0000 in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 03-28-2003, 06:22 AM
  5. I am developing a VB application which calculates ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 04-04-2002, 02:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66