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

Need Help with memory managment.

This is a discussion on Need Help with memory managment. within the MapPoint Desktop 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 ...

  1. #1
    PMACAFEE is offline 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?

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

    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.

  3. #3
    PMACAFEE is offline 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.

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

    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.

  5. #5
    PMACAFEE is offline 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.

  6. #6
    PMACAFEE is offline 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.

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

    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).

  8. #8
    PMACAFEE is offline 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

Thread Information

Users Browsing this Thread

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

Similar Threads

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