×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Unhappy Memory Leak when removing and adding markers.

    Sample code below - very simple map, adds and removes markers on a timer.

    Using Chrome dev tools, can see memory rapidly climb from 11 megs, to 50 megs megs, within 6 minutes. (see http://i.imgur.com/EN23tBX.png)

    addMarkersWithCleanup() is an attempt to aggressively destroy the objects myself. Makes no difference.

    Manually invoking the chrome garbage collector does not help.

    Is there some different way we should be removing markers? If not, this definitely seems like a definite leak.

    On our actual app, this is resulting a loss of 300kb every 10 seconds, and the app is meant to stay open for hours on end...

    Thanks.

    Code:
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<WipViewModel>" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Nokia map - Memory test</title>
    </head>
    <body>
        <div id="mapContainer" style="width: 1024px; height: 768px;">
        </div>
        <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=maps,datarendering"></script>
        <script>
            nokia.Settings.set("appId", "<%= Model.NokiaMapAppId %>");
            nokia.Settings.set("authenticationToken", "<%= Model.NokiaMapAuthenticationToken %>");
            var UK_COORDINATE = { latitude: 52.308479, longitude: -1.351318 };
    
            // Get the DOM node to which we will append the map
            var mapContainer = document.getElementById("mapContainer");
            // Create a map inside the map container DOM node
            var map = new nokia.maps.map.Display(mapContainer, {
                // Initial center and zoom level of the map
                center: UK_COORDINATE,
                zoomLevel: 7,
                // We add the behavior component to allow panning / zooming of the map
                components: [new nokia.maps.map.component.Behavior()]
            });
    
            
            setInterval(addMarkersWithCleanup, 3000);
    
            // This function just add markers and clear them from the list itself
            function addMarkers() {
                console.log("Clearing markers");
                map.objects.clear();
    
                console.log("Adding markers");
                for (var i = 0; i < 50; i++) {
                    var standardMarker = new nokia.maps.map.StandardMarker(getRandomCoordinate());
                    // Next we need to add it to the map's object collection so it will be rendered onto the map.
                    map.objects.add(standardMarker);
                }
                console.log("All markers added");
            }
    
            // This function adds markers and destroy them which remove them from any display
            function addMarkersWithCleanup() {
                var size = map.objects.getLength();
                
                console.log("Total objects on map before adding: " + size);
                if (size > 0) {
                    console.log("Destroying all objects");
                    for (var i = 0; i < size; i++) {
                        var marker = map.objects.get(0);
                        marker.destroy();
                    }
                    size = map.objects.getLength();
                    console.log("Total objects remaining after clean up:  " + size);
                }
                
                size = map.objects.getLength();
                // Only add if we are sure there is nothing left on the map
                if (size <= 0) {
                    console.log("Adding markers");
                    for (var i = 0; i < 200; i++) {
                        var standardMarker = new nokia.maps.map.StandardMarker(getRandomCoordinate());
                        // Next we need to add it to the map's object collection so it will be rendered onto the map.
                        map.objects.add(standardMarker);
                    }
                    console.log("All markers added");
                }
    
    
            }
    
            function getRandomCoordinate() {
                return new nokia.maps.geo.Coordinate(this.getRandomNumber(50, 60), this.getRandomNumber(-1, -5));
            }
            function getRandomNumber(min, max) {
                return parseFloat((Math.random() * (max - min + 1) + min).toFixed(6));
            }
    
        </script>
    </body>
    </html>

  2. #2
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Yes, this is a known issue when ramping up a large number of markers over time, This issue had already been raised internally and the team responsible are investigating.

    I have a workaround suggestion (for now), rather than adding new markers each time, why not recycle them?

    1. create a MapContainer 1
    2. create a MapContainer 2
    3. Add markers to MapContainer 1
    4. Add MapContainer 1 to the map. and make it visible.

    then on the first refresh
    1. Add markers to MapContainer 2
    2. Add MapContainer 2 to the map. and make it visible.
    3. remove MapContainer 1 from the map. and make it invisible and make all the markers invisible.


    then on the second refresh
    1. Instead of adding markers, alter the coordinates of the markers in MapContainer 1, make them visible
    2. remove MapContainer 2 from the map. and make it invisible and make all the markers invisible.
    3. Add MapContainer 1 to the map. and make it visible.


    then on the third refresh
    1. Instead of adding markers, alter the coordinates of the markers in MapContainer 2, make them visible
    2. remove MapContainer 1 from the map. and make it invisible and make all the markers invisible.
    3. Add MapContainer 2 to the map. and make it visible.


    and so on....


    This avoids using clear(), which appears to be at fault. I'll see if I can knock up an example.

  3. #3
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Quote Originally Posted by jasfox View Post
    I'll see if I can knock up an example.
    Code:
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Nokia map - Memory test</title>
    </head>
    <body>
        <div id="mapContainer" style="width: 1024px; height: 768px;">
        </div>
        <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=maps,datarendering"></script>
        <script>
            nokia.Settings.set("appId", "APP_ID"); 
    		nokia.Settings.set("authenticationToken", "TOKEN");
            var UK_COORDINATE = { latitude: 52.308479, longitude: -1.351318 };
    
            // Get the DOM node to which we will append the map
            var mapContainer = document.getElementById("mapContainer");
            var container1 = new nokia.maps.map.Container();
            var container2 = new nokia.maps.map.Container();
            // Create a map inside the map container DOM node
            var map = new nokia.maps.map.Display(mapContainer, {
                // Initial center and zoom level of the map
                center: UK_COORDINATE,
                zoomLevel: 7,
                // We add the behavior component to allow panning / zooming of the map
                components: [new nokia.maps.map.component.Behavior()]
            });
            
            var useFirstContainer = true;        
            
            setInterval(addMarkersWithCleanup, 1000);
    
            // This function just add markers and clear them from the list itself
            function addMarkers(container) {           
                for (var i = 0; i < 50; i++) {
                	if (i < container.objects.getLength()){
                		console.log("Move markers");
                    	container.objects.get(i).set("coordinate", getRandomCoordinate());
                    } else {
                    	console.log("Adding markers");
                    	 var standardMarker = new nokia.maps.map.StandardMarker(getRandomCoordinate());
                    	container.objects.add(standardMarker);
                    }
                }
                console.log("All markers added");
            }
    
            // This function adds markers and destroy them which remove them from any display
            function addMarkersWithCleanup() {
            	if (useFirstContainer){
    	            addMarkers(container1);
    	            map.objects.add(container1);
    	            map.objects.remove(container2);
    	        	useFirstContainer = false;	
            	} else {
            		addMarkers(container2);
    	            map.objects.add(container2);
    	            map.objects.remove(container1);
    	        	useFirstContainer = true;	
                }           
            }
    
    
    
            function getRandomCoordinate() {
                return new nokia.maps.geo.Coordinate(this.getRandomNumber(50, 60), this.getRandomNumber(-1, -5));
            }
            function getRandomNumber(min, max) {
                return parseFloat((Math.random() * (max - min + 1) + min).toFixed(6));
            }
    
        </script>
    </body>
    </html>

  4. #4
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    Many thanks for the quick response and sample code Jason.

    Our first intuition was to do exactly that, but we ran into issues with the cluster provider (not shown in the example code) not updating correctly, and we couldn't find a method to get it to do so. I can get my colleague to post the details if you think its possible to fix that?

    Do you have any idea of a rough timeline for the underlying memory issue here being fixed?

    Thanks.

  5. #5
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Quote Originally Posted by tktr View Post
    Many thanks for the quick response and sample code Jason.
    No problem - all part of the service.

    Quote Originally Posted by tktr View Post
    we ran into issues with the cluster provider...
    If you could post a sample I could try looking at it, but even without seeing the code I have a suggestion. Given your aggressively updating use case, it would seem that you may be better off clustering server side rather than relying on the client - this can be particularly slow in the case of older browsers - I'd look at something like the HTML example here - This example just uses standard markers for the clusters, but there is no reason why you couldn't use SVG or something like that. You could periodically request based on the view port and zoom level. Obviously the more you can hive off to the back-end the better (at the potential cost of more data traffic)

    Quote Originally Posted by tktr View Post
    Do you have any idea of a rough timeline for the underlying memory issue here being fixed?
    I wouldn't like to give a timeline unless I was 100% sure of a release date. Unfortunately there isn't a proper mechanism for following bug fixes/feature requests at the moment as this is also one of the items on the internal to-do list.

  6. #6
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    Greetings, I am working with tktr.

    Our tool is currently using the ClusterProvider component (client-side). We are not using a server-side component as we are not dealing with a large number of markers to justify it.

    We can have between 0 to 200 markers, refreshed every 20-30secs.

    We also use a custom implementation of ITheme which returns custom markers.

    With the below code, a memory leak is also observed.

    Code:
    <script>
    
            var UK_COORDINATE = { latitude: 52.308479, longitude: -1.351318 };
    
            // Get the DOM node to which we will append the map
            var mapContainer = document.getElementById("mapContainer");
            // Create a map inside the map container DOM node
            var map = new nokia.maps.map.Display(mapContainer, {
                // Initial center and zoom level of the map
                center: UK_COORDINATE,
                zoomLevel: 7,
                // We add the behavior component to allow panning / zooming of the map
                components: [new nokia.maps.map.component.Behavior()]
            });
    
            var myTheme = {
                getClusterPresentation: getClusterPresentation,
                getNoisePresentation: getNoisePresentation
            };
            var ClusterProvider = nokia.maps.clustering.ClusterProvider,
            clusterProvider = new ClusterProvider(this.map, {
                eps: 16,
                minPts: 1,
                dataPoints: [],
                theme: myTheme
            });
    
            addMarkersToCluster();
            setInterval(addMarkersToCluster, 10000);
            function getClusterPresentation(dataPoints) {
                if (dataPoints.getSize() > 0) {
                    // Just add a Standard Marker for now.
                    return new nokia.maps.map.StandardMarker(dataPoints.getBounds().getCenter(),
                        				{
                        				    text: dataPoints.getSize(),
                        				    brush: { color: '#FF0000' }
                        				}
                        		);
                }
    
            }
            function getNoisePresentation(dataPoint) {
                return new nokia.maps.map.StandardMarker([dataPoint.latitude, dataPoint.longitude]);
            }
    
            function addMarkersToCluster() {
                console.log("Removing all points from cluster provider");
                clusterProvider.clean();
                for (var i = 0; i < 50; i++) {
                    var coordinate = getRandomCoordinate();
                    clusterProvider.add(coordinate);
                }
                var size = clusterProvider.getDataLength();
                if (size > 0) {
                    console.log(size + " points added to cluster");
                    clusterProvider.cluster();
                } else {
                    console.error("No point was added to cluster provider");
                }
            }
    
    </script>
    Taking your idea of using 2 containers and recycling existing markers, what would you suggest us to do with the cluster provider ? Can we have control over the internal markers of a cluster and update their coordinates ?

    The memory leak in our tool is quite severe. On first load the memory usage is about 6mb. After about 10 minutes it reaches 16Mb. I left it over night and it reached over 400mb.

  7. #7
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    This is how I would attempt to recycle Markers within a cluster. container1 is just a bag which is never added to the map.

    Code:
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Nokia map - Memory test</title>
    </head>
    <body>
        <div id="mapContainer" style="width: 1024px; height: 768px;">
        </div>
        <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=maps,datarendering"></script>
        <script>
            nokia.Settings.set("appId", "APP_ID"); 
    		nokia.Settings.set("authenticationToken", "TOKEN");
            
            var UK_COORDINATE = { latitude: 52.308479, longitude: -1.351318 };
            // Get the DOM node to which we will append the map
            var mapContainer = document.getElementById("mapContainer");
            var container1 = new nokia.maps.map.Container();
            var container2 = new nokia.maps.map.Container();
            // Create a map inside the map container DOM node
            var map = new nokia.maps.map.Display(mapContainer, {
                // Initial center and zoom level of the map
                center: UK_COORDINATE,
                zoomLevel: 7,
                // We add the behavior component to allow panning / zooming of the map
                components: [new nokia.maps.map.component.Behavior()]
            });
    
            var myTheme = {
                getClusterPresentation: getClusterPresentation,
                getNoisePresentation: getNoisePresentation
            };
            var ClusterProvider = nokia.maps.clustering.ClusterProvider,
            clusterProvider = new ClusterProvider(this.map, {
                eps: 16,
                minPts: 1,
                dataPoints: [],
                theme: myTheme
            });
            
             var useFirstContainer = true;   
    
            //addMarkersWithCleanup();
            
            var count = 0;
            addMarkersToCluster();
            
            
            
            setInterval(addMarkersToCluster, 1000);
            function getClusterPresentation(dataPoints) {
                if (dataPoints.getSize() > 0) {
                    // Just add a Standard Marker for now.
                   var marker;
    	        	if (count < container1.objects.getLength()){
    	        		marker = container1.objects.get(count);
    	        		marker.set("coordinate", dataPoints.getBounds().getCenter());        	
    	        		map.objects.remove(marker);
    	        	} else {
    	        		marker = new nokia.maps.map.StandardMarker(dataPoints.getBounds().getCenter());        
    	        		container1.objects.add(marker);
    	        	}
    	        	marker.set ("text", dataPoints.getSize());
    	        	marker.set("brush", { color: '#00FF00' });
    	        	marker.set("visible", true); 
    	        	
    	        	count++;
    	            return marker;
                }
    
            }
            function getNoisePresentation(dataPoint) {
            	var marker;
            	if (count < container1.objects.getLength()){
            		marker = container1.objects.get(count);        		
            		map.objects.remove(marker);
            	} else {
            		marker = new nokia.maps.map.StandardMarker(dataPoint);
            		container1.objects.add(marker);
            	}
            	
            	marker.set("coordinate", dataPoint);
            	marker.set ("text", "");
            	marker.set("brush", { color: '#FF0000' });
            	marker.set("visible", true);   
            	
            	count++;
                return marker;
            }
    
            function addMarkersToCluster() {
                console.log("Removing all points from cluster provider");
                count = 0;
                clusterProvider.clean();
                
                for (var i = 0; i <  container1.objects.getLength(); i++){
                	 container1.objects.get(i).set("visible", false); 
                	 map.objects.remove( container1.objects.get(i));  
                }
                
                
                for (var i = 0; i < 50; i++) {
                    var coordinate = getRandomCoordinate();
                    clusterProvider.add(coordinate);
                }
                var size = clusterProvider.getDataLength();
                if (size > 0) {
                    console.log(size + " points added to cluster");
                    clusterProvider.cluster();
                } else {
                    console.error("No point was added to cluster provider");
                }
            }
       
    
    
    
    
            function getRandomCoordinate() {
                return new nokia.maps.geo.Coordinate(this.getRandomNumber(50, 60), this.getRandomNumber(-1, -5));
            }
            function getRandomNumber(min, max) {
                return parseFloat((Math.random() * (max - min + 1) + min).toFixed(6));
            }
    
        </script>
    </body>
    </html>
    Last edited by jasfox; 2013-05-02 at 11:44.

  8. #8
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    Thanks.

    However the memory leak is still present. I have got about 18000 geoCoordinate objects left in memory after running it for an hour.

    50 objects refreshed every 10 seconds over an hour = 18 000.

    Initial heap dump size : ~5mb.
    After an hour: ~18mb.

    Those numbers were taken from the Chrome Developer Tools, taking heap snapshots.

  9. #9
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Quote Originally Posted by JeanT View Post
    ... I have got about 18000 geoCoordinate objects left in memory after running it for an hour.
    My guess is that because the test harness keeps creating new geoCoordinates in the getRandomCoordinate() method - the sample code only recycled the markers.

    If you take the population of German file from here : http://www.developer.nokia.com/Commu...20120710130038

    Include this line in the header:


    Code:
    <script type="text/javascript" charset="UTF-8" src="./german_pop_lat_long.js"></script>
    and alter the addMarkersToCluster() method as shown:

    Code:
    /* for (var i = 0; i < 50; i++) {
                    var coordinate = getRandomCoordinate();
                    clusterProvider.add(coordinate);
                }*/
                clusterProvider.addAll(popData);
    Then I don't see a memory leak - refreshing the same dataset with the original code does show the leak though.
    Last edited by jasfox; 2013-05-02 at 14:58.

  10. #10
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    The memory leak is not present in the example given above because in it you are manipulating a fixed array of items that never changes. However we must be able to remove datapoints so that they are not included in the computing of clustered points, as the base list of things we want to display changes. We have a list of vehicles, and some of them are toggled on/off....

    While the below code is working (ie no memory leak), it will not work in the real application because every refresh may not have the same amount of data points.

    Code:
           function addMarkersToCluster() {
                console.log("Removing all points from cluster provider");
                count = 0;
                //clusterProvider.clean();
    
                for (var i = 0; i < container1.objects.getLength() ; i++) {
                    container1.objects.get(i).set("visible", false);
                    map.objects.remove(container1.objects.get(i));
                }
    
    
    	    // We only add on load, then update existing geoCoordinates.
                if (points.length == 0) {
                    console.log("Adding new coordinates");
                    for (var i = 0; i < 50; i++) {
                        var coordinate = getRandomCoordinate();
                        points.push(coordinate);
                    }
                    clusterProvider.addAll(points);
                } else {
                    console.log("Updating existing coordinates");
                    // Even the geoCoordinate is still held in memory after cleaning the cluster provider data so we have to update the existing array elements
                    for (var i = 0; i < 50; i++) {
                        var coordinate = getRandomCoordinate();
                        var o = l[i];
                        o.latitude = coordinate.latitude;
                        o.longitude = coordinate.longitude;
                    }
                }
                //clusterProvider.addAll(popData);
                var size = clusterProvider.getDataLength();
                if (size > 0) {
                    console.log(size + " points added to cluster");
                    clusterProvider.cluster();
                } else {
                    console.error("No point was added to cluster provider");
                }
            }

  11. #11
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    Hi Jason,

    Many thanks for your replies on this.

    Unfortunately, we are really stuck here. We've developed our app with Nokia maps, but now cannot launch, and business is Not Happy. The work around doesn't appear to get us out of this hole, as something within the map is holding a reference back out to our array.

    Unless we have some idea of when you will fix this issue, we'll have to cut our losses, switch to a competitor and rewrite. Which obviously we're really prefer not to do. Are you able to supply any ETA an a fix to avoid us having to do that please?

    Many thanks.

  12. #12
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Quote Originally Posted by JeanT View Post
    The memory leak is not present in the example given above because in it you are manipulating a fixed array of items that never changes. However we must be able to remove datapoints so that they are not included in the computing of clustered points, as the base list of things we want to display changes. We have a list of vehicles, and some of them are toggled on/off....

    While the below code is working (i.e. no memory leak), it will not work in the real application because every refresh may not have the same amount of data points.

    I believe the real reason my static data example works, and your alternative does not, is not because I am repeatedly displaying the same array, but it is because I am creating an array of IPoints and you are creating an array of Coordinates. My guess is that there are two potential leaks - Marker and Coordinate. This is what I mean by "My guess is that because the test harness keeps creating new geoCoordinates in the getRandomCoordinate() method"

    The example below moves a variable number of random markers around the UK rather than using the German static data set. After 10 minutes I see no rise in resources.

    Code:
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Nokia map - Memory test</title>
    </head>
    <body>
        <div id="mapContainer" style="width: 1024px; height: 768px;">
        </div>
        <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=maps,datarendering"></script>
        <script>
            nokia.Settings.set("appId", "APP_ID"); 
    		nokia.Settings.set("authenticationToken", "TOKEN");
            
            var UK_COORDINATE = { latitude: 52.308479, longitude: -1.351318 };
            // Get the DOM node to which we will append the map
            var mapContainer = document.getElementById("mapContainer");
            var container1 = new nokia.maps.map.Container();
            var container2 = new nokia.maps.map.Container();
            // Create a map inside the map container DOM node
            var map = new nokia.maps.map.Display(mapContainer, {
                // Initial center and zoom level of the map
                center: UK_COORDINATE,
                zoomLevel: 7,
                // We add the behavior component to allow panning / zooming of the map
                components: [new nokia.maps.map.component.Behavior()]
            });
    
            var myTheme = {
                getClusterPresentation: getClusterPresentation,
                getNoisePresentation: getNoisePresentation
            };
            var ClusterProvider = nokia.maps.clustering.ClusterProvider,
            clusterProvider = new ClusterProvider(this.map, {
                eps: 16,
                minPts: 1,
                dataPoints: [],
                theme: myTheme
            });
            
             var useFirstContainer = true;   
    
            //addMarkersWithCleanup();
            
            var count = 0;
            addMarkersToCluster();
            
            
            
            setInterval(addMarkersToCluster, 1000);
            function getClusterPresentation(dataPoints) {
                if (dataPoints.getSize() > 0) {
                    // Just add a Standard Marker for now.
                   var marker;
    	        	if (count < container1.objects.getLength()){
    	        		marker = container1.objects.get(count);
    	        		marker.set("coordinate", dataPoints.getBounds().getCenter());        	
    	        		map.objects.remove(marker);
    	        	} else {
    	        		marker = new nokia.maps.map.StandardMarker(dataPoints.getBounds().getCenter());        
    	        		container1.objects.add(marker);
    	        	}
    	        	marker.set ("text", dataPoints.getSize());
    	        	marker.set("brush", { color: '#00FF00' });
    	        	marker.set("visible", true); 
    	        	
    	        	count++;
    	            return marker;
                }
    
            }
            function getNoisePresentation(dataPoint) {
            	var marker;
            	if (count < container1.objects.getLength()){
            		marker = container1.objects.get(count);        		
            		map.objects.remove(marker);
            	} else {
            		marker = new nokia.maps.map.StandardMarker(dataPoint);
            		container1.objects.add(marker);
            	}
            	
            	marker.set("coordinate", dataPoint);
            	marker.set ("text", "");
            	marker.set("brush", { color: '#FF0000' });
            	marker.set("visible", true);   
            	
            	count++;
                return marker;
            }
    
            function addMarkersToCluster() {
                console.log("Removing all points from cluster provider");
                count = 0;
                clusterProvider.clean();
                
                for (var i = 0; i <  container1.objects.getLength(); i++){
                	 container1.objects.get(i).set("visible", false); 
                	 map.objects.remove( container1.objects.get(i));  
                }
                
                 var numItems = 80- (Math.random()*40);
                for (var i = 0; i < numItems; i++) {
                    var coordinate  = {latitude : UK_COORDINATE.latitude + 5 - (Math.random()*10),
                					 longitude:    UK_COORDINATE.longitude  + 5 - (Math.random()*10)};
                    clusterProvider.add(coordinate);               
                }
                var size = clusterProvider.getDataLength();
                if (size > 0) {
                    console.log(size + " points added to cluster");
                    clusterProvider.cluster();
                } else {
                    console.error("No point was added to cluster provider");
                }
            }
       
    
    
    
    
            /*function getRandomCoordinate() {
                return new nokia.maps.geo.Coordinate(this.getRandomNumber(50, 60), this.getRandomNumber(-1, -5));
            }
            function getRandomNumber(min, max) {
                return parseFloat((Math.random() * (max - min + 1) + min).toFixed(6));
            }*/
    
        </script>
    </body>
    </html>
    Last edited by jasfox; 2013-05-07 at 16:31.

  13. #13
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Memory Leak when removing and adding markers.

    Quote Originally Posted by tktr View Post
    Unfortunately, we are really stuck here.....
    I appreciate your frustration - as I mentioned previously the issue is known about internally. Unfortunately the technical advice I can offer has to work within the limitations of the current release of the API (hence the workarounds).

    Quote Originally Posted by tktr View Post
    The work around doesn't appear to get us out of this hole,......
    I hope the explanation encouraging you to use of IPoint and avoid Coordinate in your use case will help. I know it is a hack, but it seem to work for me. The good news is that the memory test has now run for half an hour without a significant slope on the Memory plot.

    Quote Originally Posted by tktr View Post
    Unless we have some idea of when you will fix this issue, we'll have to cut our losses, switch to a competitor and rewrite. Which obviously we're really prefer not to do. Are you able to supply any ETA an a fix to avoid us having to do that please?
    Since I don't write the API, I just use it, I cannot justifiably supply a commitment to an ETA. You would have a lot more leverage to get a definitive date on this if you are a paying customer through talking to your sales representative.

  14. #14
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    Re: Memory Leak when removing and adding markers.

    Thanks Jason, much appreciated.

    It appears the workaround is now working. But having to code this way is not ideal - so I'd still be very interested to hear an ETA from the relevant department when one becomes available please (there must be a timeline somewhere!) - as it can guide us on future use.

    Thanks again.

  15. #15
    Super Contributor
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: Memory Leak when removing and adding markers.

    FYI, the moderation team picked this discussion to "feature" this week. See here.

Similar Threads

  1. Adding infobubble on shape click, performance with many markers/shapes
    By guard1an2 in forum [Archived] MH5: Nokia Maps Framework for mobile HTML5
    Replies: 2
    Last Post: 2013-01-11, 12:42
  2. Memory card Adding and removing
    By gracy in forum Mobile Java General
    Replies: 1
    Last Post: 2011-01-10, 06:11
  3. memory leak on emulator = memory leak on device
    By manmli in forum Mobile Java General
    Replies: 2
    Last Post: 2006-08-05, 19:54
  4. RPointerArray adding/removing.
    By kota in forum Symbian C++
    Replies: 1
    Last Post: 2006-08-03, 02:36
  5. RPointerArray adding/removing.
    By kota in forum Mobile Java General
    Replies: 0
    Last Post: 2006-08-02, 15:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •