MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Need Help with memory managment.

This is a discussion on Need Help with memory managment. within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I have read as many posts here as possible regarding memory managment and now need help with priorities in keeping ...


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

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



Click here to register

Reply

 

LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-28-2006
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 41
Need Help with memory managment.

I have read as many posts here as possible regarding memory managment and now need help with priorities in keeping my application stable and running smoothly.

I have an MS Access 2000 application using the Mappoint OCX control. The application gets very slow after just a few minutes. I understand the the minimize/maximize window routine will not be of any benefit on my Access form.
I plan to release memory from objects whenever I can and probably schedule a map save/restore periodically to free up whatever else I can.

I assume the objects that need addressing are the map, locations, pushpins, and routes:
objmap, objloc, objpushpin, and objroute.

Here is how those variables are used:

My application will track about 10 vehicle and about 60 locations per vehicle. Because of weak GPS signals, many position reports falsely report 0 speed and 0 heading. I use a distance/time calulation to previous points to guess if the vehicle is moving or not.

Because of stopped vehicles, I have fewer pushpins than locations.

Routing is only used sporatically to show a path from the most recent location to a destination but it re-calculated every time the vehicle moves.

Can someone please first confirm that these simple steps (**) would be appropriate for memory management?

When (objroute.delete) then
(**) objroute = nothing ?
(**) objroute = objmap.route ?

When objmap.Datasets(1).delete
(**) I loop through and set all the pushpins to nothing ?
(Wilfried has kindly given me a loop to step through all my pushpins)

I use an array of locations objloc(1-60) every time I display a set of points. I use the same arrary over and over after clearing the dataset.

Do I need to;
(**) set each objloc to nothing before I re-use it?

Finally, I wll save the map to disk every 15 minutes or so and then reload it.
Do I need to set these before I re-load the map?
(**) objmap=nothing ?
(**) objmap =Mapcntrl.map ?
(**) objroute = nothing ?
(**) objroute = objmap.objroute ?

These techniques have been discussed here in various posts, but not all in relation to one programming tool or display environment.

Can anyone help in evaluating these techniques?
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 11-29-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: Need Help with memory managment.

Hi,

Setting the object to nothing before assigning it again will not make any difference. What could make difference is setting it to Nothing the moment you dont need it anymore. This is not needed if the object is a pointer on the stack in a function, because as soon as the function return that part of the stack is not reacheable and objects should be freed.
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 11-29-2006
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 41
Re: Need Help with memory managment.

I am definitely doing something wrong, maybe using a dim statement inside or loop or something else that improperly uses resources. I am not a programmer by profession, and my inexperience is beginning to show now that I want to deploy the app that I spent the last couple of weeks working on.

Everyone in the office loves the app for about 15 minutes and then it becomes unusable.
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 11-29-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: Need Help with memory managment.

Hi,

I know nothing of VB or VBA but trying You mention a Dim statement inside a loop. Whell as far as I can see in VB code the Dim does assign (or assign and create) the object in question (correct me if I'm wrong).

Now suppose you do this (dont matter the syntax I dont know):
Code:
while (someCondition) do
   Dim Foo as integer;
   // ...
This will not harm. the integer Foo is just placed on the stack. Nothing is allocated. But now this:
Code:
while (someCondition) do
   Dim Foo as someObject;
   // ...
While Foo is also just an integer (yeah in fact it is a pointer to the object) and just placed on the stack as in previous example, the object someObject is created here. In the next irretation of the loop, the object where Foo points to is destroyed and a new someObject will create. So here is a lot of memory allocation / deallocation. While is is consuming mutch time it will also fragment memory because the deallocation is not nececary immediatly.

Even in dotNet you can this way easy fragment memory even with the nice garbage collector

Hope this helps understeanding ? Hope my explanation make sence. English is not my native language.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 11-29-2006
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 41
Re: Need Help with memory managment.

Wilfried;

Thanks for the quick reply. Your comments probably stopped some unnecessary re-writes. I will now go through my code looking for objects that are dimmed within the loop. I think that I did most of the dim statements at the top and did the "set" within the loop.

Thanks once again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 11-30-2006
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 41
Re: Need Help with memory managment.

OK, I think I figured it out. Sort of a DUH! though.

I was using the same routine over and over to add my custom pushpin symbols and never reusing them. So I have thousand of pushpin symbols in the set.

I need to load about 75 images and then be able to refer to them by ID number. Can anyone think of a easy programatic way to add and then refer to the numbers. It would seem that I would need to get the number after they were added and then create an array or tabe with the ID number and the name of the image in each record. Then I would use a lookup query to get the image number and then refer to it.

Or something like that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 11-30-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: Need Help with memory managment.

Hi,

Glad first problem is solved

Can you clarify the last question in more simple Englisch ? (English is not my native language).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 12-01-2006
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 41
Re: Need Help with memory managment.

I resolved the problem in a similar post. At the time I knew that I had to import 75 custom pushpin symbols to illustrate my vehicle tracking program. When they are imported Mappoint assignes them a simbol.Id number beginning with 336. I could not figure out a way to refer to the proper symbol after they were imported without building a lookup table as I imported the symbols. Then I found out that I can call the symbols by name and that the symbol name is the same as theie dos file name. Here is the solution I posted in the other thread:

______________________________

That one I got on my own after some tinkering around. I have loaded the 75 icons into a map through the Mappoint application using the icon loader suggested in another of my posts here.

I save the map, because the user added icons are saved in the map. That way I have an expanded library without having to load every time.

When running my Access application, I first load the map with the icons installed and then I call them by the file name they had when loaded.

I use:
objPushPin(xy).Symbol = objmap.Symbols.Item("Car.bmp")

It seems to work fine and the program is so far stable.

Thanks for all your help
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
managment, memory


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/need-help-memory-managment-5412.html

Posted By For Type Date
The Magazine for MapPoint - MP2K Magazine This thread Refback 11-28-2006 02:31 PM

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
Mappoint 2006 memory Leak? EvetsMostel MapPoint 2006/2009 Discussion 10 12-22-2006 03:13 AM
Add-in / MP2006 Memory Clash? Winwaed MapPoint 2006/2009 Discussion 0 11-27-2006 06:00 PM
Free Memory - no Visual MapPoint robinsongm MapPoint 2006/2009 Discussion 3 09-14-2006 02:12 AM
Fleet2Track FLEET MANAGMENT & SATELLITE LOCALIZATION zibiboniek News and Announcements 0 07-21-2005 11:40 AM
Memory leaks in MapPoint rbarthels MapPoint 2006/2009 Discussion 2 01-27-2004 05:53 PM


All times are GMT -5. The time now is 05:50 AM.


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