Quantcast
Channel: Huge Memory Leak in 6.2
Viewing all articles
Browse latest Browse all 2

Huge Memory Leak in 6.2

$
0
0
There seems to be a huge memory leak when loading new geoRss layers onto the map.  Every 5 minutes, my map deletes the old RSS layer and loads a new one.  I ran it through a memory leak tool called sIEve and it looks like the pushpin mouseover events are never getting disposed of.  I have tried: map.DeleteAllShapeLayers, map.Dispose, map.DeleteAllShapes, map.DeleteAllPushpins, individually and in every possible permutation with no success.  Memory usage increases approximately 1.5MB per update. 

 

 

 

 

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>

<script>

var map = null;
var mapLayer = null;
var rssSource = null;
var numShapes = null;
var shape = null;
var veLayerSpec = null;

function GetMap() {
    try {

        map = new VEMap('myMap');
        map.LoadMap(null, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, false);

        var urlString = window.location.search.substring(1);
        var parm = urlString.split('&');
        var pos = parm[0].indexOf('=');

        var val = parm[0].substring(pos + 1);

        if (val == "op1") {
            rssSource = "Feed1.xml";
        }
        else {
            rssSource = "Feed2.xml";
        }
        loadLayer();
    }
    catch (err) {
        alert(err.description);
    }
}

function onAsynchReturn() {
    try {
        map.DeleteAllShapes();
        map.DeleteAllShapeLayers();

        loadLayer();
    }
    catch (err) {
        alert(err.description);
    }

}

function loadLayer() {
    mapLayer = new VEShapeLayer();
    veLayerSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, rssSource, mapLayer);
    map.ImportShapeLayerData(veLayerSpec, onFeedLoad);

}

function onFeedLoad(layer) {
    numShapes = layer.GetShapeCount();

    for (var i = 0; i < numShapes; i++) {
        shape = layer.GetShapeByIndex(i);
        shape.SetCustomIcon("<img src='" + shape.IconId + "'/>");
        shape = null;
    }
}

//Tried everything here
function onAsynchBegin() {
    if (map != null) {

        //map.DeleteAllShapeLayers();
        //map.Dispose();
        //map = null;
        //map.DeleteAllPushpins();
        mapLayer = null;
    }
}

function onPageUnload() {
    map.Dispose();
}
</script>

</head>
<form id="form1" runat="server">
<body onload="GetMap();">

    <script type="text/javascript">
        Sys.Application.add_unload(onPageUnload);
        Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(onAsynchBegin);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(onAsynchReturn);
    </script>

    <div>
        <div id='myMap' style="position: relative; width: 881px; height: 617px;">
        </div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    </div>
    <asp:UpdatePanel ID="uPnlBranchMap" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Timer ID="Timer1" runat="server" Interval="300000">
            </asp:Timer>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <div style="padding-left: 700px">
                Updating Map...
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</body>
</form>
</html>


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images