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 4 of 4

MP eats up Ram with multiple routes despite clearing.

This is a discussion on MP eats up Ram with multiple routes despite clearing. within the Development forums, part of the MapPoint Desktop Discussion category; I'm running batches of zipcodes thru MP2006/2009 to calculate driving distances between them. Automated via C# which sets Waypoints, gets ...

  1. #1
    oran is offline Junior Member Yellow Belt
    Join Date
    Jul 2008
    Posts
    13

    MP eats up Ram with multiple routes despite clearing.

    I'm running batches of zipcodes thru MP2006/2009 to calculate driving distances between them. Automated via C# which sets Waypoints, gets results and moves on to the next pair of zips.

    Sample code:
    MapPoint.ApplicationClass objApp = new MapPoint.ApplicationClass();

    MapPoint.Map objMap = null;
    objApp.Visible = false; //make map not show or launch window

    objMap = objApp.ActiveMap;


    MapPoint.FindResults findResults1 = objMap.FindResults(braddr);
    MapPoint.FindResults findResults2 = objMap.FindResults(custaddr);

    objMap.ActiveRoute.Waypoints.Add(objMap.FindResult s(braddr).get_Item(ref obj1), "");
    objMap.ActiveRoute.Waypoints.Add(objMap.FindResult s(custaddr).get_Item(ref obj1), "");
    objMap.ActiveRoute.Calculate();//calculates map and route

    distance = (objMap.ActiveRoute.Distance * 2);//doubled for roundtrip numbers
    objMap.ActiveRoute.Clear();//clears out route info


    objApp.ActiveMap.Saved = true;//remove pesky popup requesting you to save map
    objApp.Quit();//make mappoint.exe close -- takes a few seconds (in the background)
    objApp = null;


    Pretty standard stuff. But the constant opening and closing of Mappoint makes it slow and MP doesn't always get closed before it's asked to open again.

    So I rewrote the code so I open MP once, then loop thru my pairs of zips and when finished close MP.

    This works fine and is faster BUT...

    With Task Manager open I can see MP eating up RAM, about 2k-5K per calculation and despite telling it to CLear the route I NEVER see the memory used go down , it just keeps incrementing upwards. When it hits 450M it stops because my sever says "enough!"

    Any ideas on how to make it release the memory it's chewing up?
    Last edited by oran; 10-03-2008 at 09:04 AM.

  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

    Re: MP eats up Ram with multiple routes despite clearing.

    This is to do with garbage disposal. MapPoint is pretty lazy when it comes to garbage disposal and will do what you describe until physical memory becomes a problem. Considering MapPoint is primarily designed for GUI users, this makes sense. (although a manual GC call in the API would be useful!).

    One solution is to minimize and maximize MapPoint. You have to do this through the Windows API - it doesn't work if you use the app windowstate property.

    <shameless plug for one of my products>
    My MPMileage program does batch MapPoint route calculation as well - start/end points are specified in a database. On a modern PC, I bet it is quicker than your code!
    MPMileage: Batch calculate mileages with Microsoft MapPoint


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

  3. #3
    dthoma is offline Junior Member White Belt
    Join Date
    Oct 2008
    Posts
    1

    Re: MP eats up Ram with multiple routes despite clearing.

    Quote Originally Posted by oran View Post

    With Task Manager open I can see MP eating up RAM, about 2k-5K per calculation and despite telling it to CLear the route I NEVER see the memory used go down , it just keeps incrementing upwards. When it hits 450M it stops because my sever says "enough!"

    Any ideas on how to make it release the memory it's chewing up?
    Just a thought ... could you count the number of zip pairs you have and divide that by a number and when those numbers hit close MP and reopen it?

    -or-

    I am not this advanced yet ... there probably is a way to look at the process and when it gets over 250M shut down MP and restart it, which would be a better way of doing it. ([vb.net] monitor process' memory usage - Neowin Forums) ... haven't tried it ... shot in the dark.

    obviously the code would have to run along side the code you listed. which would slow things up a bit.

  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

    Re: MP eats up Ram with multiple routes despite clearing.

    Counting successful routes and restarting works.

    At what point the restart occurs is a matter of choice. As memory is used up, MapPoint runs slower. But the restart process itself takes extra time. When is the optimum?


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

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with multiple routes
    By madrover in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 07-30-2006, 10:46 AM
  2. Multiple Routes
    By wadams in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-17-2005, 09:28 AM
  3. Multiple routes
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 03-23-2005, 01:11 PM
  4. Multiple routes
    By tanguy_laverdure in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 02-27-2004, 09:14 AM
  5. Multiple Routes on 1 Map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-10-2003, 09:45 PM

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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127