MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




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 2006/2009 Discussion category; I'm running batches of zipcodes thru MP2006/2009 to calculate driving distances between them. Automated via C# which sets Waypoints, gets ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-03-2008
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 10:04 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 10-03-2008
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 893
Blog Entries: 10
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
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 10-14-2008
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-15-2008
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 893
Blog Entries: 10
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
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
clearing, eats, multiple, ram, routes


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Help with multiple routes madrover MapPoint 2006/2009 Discussion 3 07-30-2006 11:46 AM
Multiple Routes wadams MapPoint 2006/2009 Discussion 0 11-17-2005 10:28 AM
Multiple routes Anonymous MapPoint 2006/2009 Discussion 2 03-23-2005 02:11 PM
Multiple routes tanguy_laverdure MapPoint 2006/2009 Discussion 0 02-27-2004 10:14 AM
Multiple Routes on 1 Map Anonymous MapPoint 2006/2009 Discussion 0 09-10-2003 10:45 PM


All times are GMT -5. The time now is 06:29 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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