V3 performance degrades over time

During my development, I had to refresh my webpage every so often. I noticed that over a period of time the map was taking longer and longer to refresh. In fact, at one point, it took 35 seconds. So, I decided to do some testing. With the help of the "window.setTimeout()" function, I automated the GetMap() function to run every 30 seconds. I calculated the time for the GetMap() function and saved it. It started out with 1 second and at the end of 30th call, it took 9 seconds. The increase was progressive and there were no spikes. I have 15 pushpins on the map. I'm using IE6.

If I close the browser and restart my application, it starts running faster but gradually slows down again.

In our production environment, I foresee my users keeping the browser open all day long and refreshing the map more than 100 times. I'm afraid, my users won't accept the slow performance.

Does anyone have any ideas/comments/suggestions



Answer this question

V3 performance degrades over time

  • Kennon2005

    Yeah this is not .net its javascript so i really don't know where those objects are going to go.
    Just adding the delete pins isn't going to work alone sorry.
    I just tried to use your code but you didn't past the whole thing, i don't have your xml etc so i can't simulate your problem.
    Try reusing the existing map object, deleting the pins then adding them.
    If this doesn't work simplify your problem, make it self contained (not xml etc) and then post it up.
    Sorry i can't be more help.
    John.


  • JonEagle

    Ok cool - so you are loading 15 pins, making the browser refresh and it gets progressivly slower.
    This doesn't sound good.
    I am refreshing the data in my grid by using a georss feed instead. This way using a js loop I can dispose of the previous layer and add the new layer of points. This also allowed me to add logic to follow moving points or not depending on what the user had done. And i don't have to render the whole page again on the server, only the xml for the data.

    I haven't come across your problem but that doesn't mean it isn't there. Post how to calulate the execution time of a js function and i'll do the same test here.

    just read your post again about using window.setTimeout(). Are you simply calling your getmap function every 30 sec You must dipose of the previous objects 1st. Very important. This could very well be the problem. Post the whole js script.
    John.




  • Marzullo

    I've noticed this issues as well just from developing and needing to refresh the page frequently. If you watch the task manager you can see the amount of memory being chewed up by IExplore.exe keeps increasing. The memory doesn't get freed from the process until I minimize the window and it doesn't clear from the overall memory usage until I close the window.

    My example:
    Simple Map with 1 Pushpin
    Started with IExplore using 21MB of Memory
    Overall Memory Usage 559MB

    After 5 Refreshes:
    IExplore: 27MB
    Overall: 567MB

    After 10 Refreshes:
    IExplore: 33MB
    Overall: 573MB

    After 15 Refreshes:
    IExplore: 38MB
    Overall: 579MB

    After minimizing Internet Explorer:
    IExplore: 2MB
    Overall: 578MB

    After maximizing the same Internet Explorer window:
    IExplore: 8MB
    Overall: 578MB

    After closing Internet Explorer:
    Overall: 537MB

    Hope this makes sense.



  • pire

    THis might solve the memory problem, but does it solve the speed issue

    I created a simple VE App, with nothing but a call to load map, and a timer that measures how long the call took.

    Even when calling the dispose method, the time increases steadily the more I refresh the page.

    Am I doing something wrong with the onunload Here is the relevant code:


    function loadMap()
    {
    var begin = new Date();
    var map = new VEMap('mapSection');
    map.LoadMap();
    var end = new Date();
    alert ('LoadMap took ' + (end - begin) + 'ms');
    }

    <body onload='loadMap();' onunload='map.Dispose()'>


  • Paulustrious

    function GetMap() {
    var lat, lon, speed, direction, time, memName;
    var locs = new Array();

    recordTime("Before LoadMap:");
    map = new VEMap('myMap');
    if (mapCenter == null) { // page/map is loaded for the first time
    map.LoadMap();
    }
    else {
    map.LoadMap(mapCenter, mapZoomLevel, mapStyle, false);
    }
    recordTime("After LoadMap - Before AddPushpin:");
    for (var i=0; i<xmlRoot.childNodes.length; i++) {
    lat = parseFloat(xmlRoot.childNodes(i).getAttribute("latitude"));
    lon = parseFloat(xmlRoot.childNodes(i).getAttribute("longitude"));
    speed = xmlRoot.childNodes(i).getAttribute("speed") + " miles/hr";
    direction = xmlRoot.childNodes(i).getAttribute("direction");
    time = xmlRoot.childNodes(i).getAttribute("lastPresence");
    memName = xmlRoot.childNodes(i).getAttribute("fullName");

    var loc = new VELatLong(lat, lon);
    locs.push(loc);

    var pin = new VEPushpin(i, loc, "images/"+(i+1).toString()+".gif", memName+" ("+(i+1).toString()+")", "<table border=0 style='font-family:Verdana;font-size:8pt;'><tr><td align='right'><b>Time:</b></td><td>" + time + "</td></tr><tr><td align='right'><b>Speed:</b></td><td>" + speed + "</td></tr> </tr><tr><td align='right'><b>Direction:</b></td><td>" + direction + "</td></tr></table>");
    map.AddPushpin(pin);
    }
    recordTime("After AddPushpin:");
    map.SetMapView(locs); // it will set the zoom level to accommodate all the pushpins
    // save map's center, zoomlevel, and style
    mapCenter = map.GetCenter();
    mapZoomLevel = map.GetZoomLevel();
    mapStyle = map.GetMapStyle();

    recordTime("Finally:");
    }

    function recordTime(msg) {
    var d = new Date();
    var currTime = d.getHours().toString() + ":" + d.getMinutes().toString() + ":" + d.getSeconds().toString();
    var elapsed = (d.getTime() - startTime)/1000;
    var str = document.getElementById("txt1").value;
    str += msg;
    str += "\n";
    str += currTime;
    str += "\nElapsed: ";
    str += elapsed;
    str += "\n";
    document.getElementById("txt1").value = str;
    }

    function refreshTimerTicked() {
    StopRefreshTimer();
    var d = new Date();
    if (d.getTime() > stopTime) {
    return;
    }
    GetMap();
    refreshTimerID = window.setTimeout("refreshTimerTicked()", 30000);
    }

    function StopRefreshTimer() {
    if(refreshTimerID) {
    window.clearTimeout(refreshTimerID);
    refreshTimerID = 0;
    }
    }


  • Butterflyangel02

    I can only suggest you reduce the set of functionlaity you are providing so you can determine the source of the problem. For example if you simple load a default map do you still get this problem or is it with the pushpins or is it more custom code Unfortunatly debugging js is too much fun.
    John.


  • Gentledepp

    Hey all - sorry for the slow response. I thought I posted this last week, but I don't see my post...

    You can call map.Dispose() in the page unload. This should clear up the memory problem.

    onUnload=map.Dispose();"

    Cheers,

    Caleb


  • C. Charpentier

    Right,

    So every 30 sec you are adding a new set of pins to the map. I can't see where you dispose of the old ones. This could be your problem. In the example of adding pins you actually give an id to reference the points - you are using i in your loop. You could loop through and remove the pins or call:

    map.DeleteAllPushpins();
    Before you add the pins.

    Give this a go and let us know if it helps.

    John.



  • Jonty-UK

    Also on top of this, do a search on "memory leaks" in the forums and it should answer all your questions.

  • samymelbourne

    Every 30 seconds I create a brand new map object. Doesn't it mean that the old one is discarded Anyway, I'll add the map.DeleteAllPushpins() line and let you know if that makes any difference. Thanks for your suggestion.

    Dilip


  • Steve Whitley

    First I call map.Load();

    Then I add 15 pushpins;

    And then I call map.SetMapView(locs); -- locs is an array of LatLong of pushpins

    Nothing fancy!!!


  • V3 performance degrades over time