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

Mappoint eats up my cpu bit by bit.

This is a discussion on Mappoint eats up my cpu bit by bit. within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello dear programmers, I'm developing an application with Mappoint using VC++. What I'm doing is getting a position from the ...

  1. #1
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Thumbs up Mappoint eats up my cpu bit by bit.

    Hello dear programmers,

    I'm developing an application with Mappoint using VC++.
    What I'm doing is getting a position from the GPS and put a smalle circle on the map. For testing I use a "static" GPS (in our office) that doesn't move, we just use it for testing. It all works well the GPS sends every second a new position (wich is finally the same position).

    But the problem is it seems that every position I get, mappoint needs more processingtime. So after a few minutes, mappoint has to process about 300 pushpins, and than the processorfan really has to cool the cpu, because Mappoint sucks almost all of the cpu.

    What I did is making a new pushpin everytime I get a new position.
    And if I want to follow a vehicle on the map with its trace (these are the old pushpins on the map) than Windows will crash after 5 minutes.

    So how can I solve this situation?

    Again, I use this everytime I get a new position:

    m_Loc = m_Map.GetLocation(Lat, Lon, 1);
    m_Pin = m_Map.AddPushpin(m_Loc.GetLocation(), Txt);
    m_Pin.SetSymbol(21);
    m_Loc.GoTo();

    I hope somebody can help me, so thank you very much

  2. #2
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Mappoint eats up my cpu bit by bit.

    Hi,

    I'm sorry I forget to mention that RAM-memory doesn't leak, so there is no memory leakage, only the cpu usage get's 100% by Mappoint only. I mean mappoint as an ActiveX ofcourse

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

    Re: Mappoint eats up my cpu bit by bit.

    Hi,

    300 pushpin is not so mutch because the map does not to handle all 300, only 1 comes new every second. Maybe the problem is because you have honderds pushpins on same location with the test ?

  4. #4
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Mappoint eats up my cpu bit by bit.

    Thank you for your reaction Wilfried,

    I don't think it has to do with the same position on the map. An the reason I think so is, I have another project wich I use it for experimenting things with mappoint.

    And the funny thing is, that I don't have that problem, though I have 500 pushpins, the cpu load remains the same. Only the RAM increases a little bit (you can see a very small change).


    So I've to figure out what's the cause of increasing the cpu-load. It's a little bit difficult to find out, because I used cut&paste, so I don't see differences in code....

    I hope someone can give a tip/tric to solve this. If I find the cause, I'll report it to you immediatly.

  5. #5
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Mappoint eats up my cpu bit by bit.

    Hello programers,

    I found out what the evil bug is (actually it's more a bad coding of mine ).
    If you look at the code below:

    void SomeFunction()
    {
    m_Loc = m_Map.GetLocation(dLat, dLon, 1);
    m_Pin = m_Map.AddPushpin(m_Loc.GetLocation(), Txt);
    m_Loc.GoTo();
    }


    Everytime I get a new latitude. longitude, I call this function to draw on the map. But by a wrong coding, Txt has the same string. Than something goes wrong, I don't really understand what's going on in Mappoint.
    But somehow if I add a pushpin on the same location with the same NAME (that's Txt stands for) than uses more processingtime.

    Can somebody explain me why that is? Because I didn't really dive in the mappoint API, I just looked for the needed functions to call, to make my application work.


    I hop somebody can tell me why Mappoint behaves like that.

  6. #6
    Naryoril is offline Junior Member White Belt
    Join Date
    Nov 2006
    Posts
    4

    Re: Mappoint eats up my cpu bit by bit.

    Do i understand you right? You add pushpins with AddPushpin(aLocation, aName) and this adding gets slower for every pushpin you add?
    If this is the case, I encountered the same problem during performance tests and found an easy but strange solution:
    don't use
    AddPushpin(aLocation, aName);

    try this one:
    pin = AddPushpin(aLocation, "");
    pin->Name = aName;


    don't ask my why this is faster, but it's really much faster, the more pushpins you already have the greater the speedup is.

    Example:
    Adding 256 pushpins to a map with an empty string as name took 4.185 seconds
    Adding 256 pushpins to a map with "moo" als name took 39.841 seconds
    Adding 256 pushpins to a map with an empty string as name followed by pin->Name = "moo" took 6.177 seconds

    It's even worse with 1024 pins:
    No name: 13.269 seconds
    "moo" as name: 38 minutes and 32.676 seconds!
    No name followed by pin->name = "moo": 23.352 seconds

    by the way, the length of the name makes only a small difference, if it's 1 character long or 50 doesn't really matter.

    edit: and using different names for each pushpin doesn't matter too if i remember right (and my pushpins had 1 distance between each other)

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

    Re: Mappoint eats up my cpu bit by bit.

    Hi,

    Thanks for feedback. Ok so that is the reason I did never encountered this problem because in each application all pushpins have exclusive name.

    Probably it has something to do with database management. I assume there is an internal index on the pushpin's name, so a internal search to it bounces on the same over and over again. Probably it increment the internal index until EOF or name change.

    I can not come to a better explanation / reason... But the nice thing is that problem is found

  8. #8
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Mappoint eats up my cpu bit by bit.

    Well,

    I hope other programmers have value information about this and I want to thank all of you.

Thread Information

Users Browsing this Thread

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

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