rama krishna

rama krishna

  • NA
  • 2
  • 2.7k

How to avoid Memoryleak with googlemap API in javascript ?

Jun 26 2014 10:25 AM

 

 

I'm using Google Maps API v3 for my c# WPF project. I have created a browser control and trying to mark the location using markers in java script. For every one second, I am updating the markers. This works fine, but there is a serious increase in memory. I feel this is because every time it needs to be created a new marker as below

var currentLatLng = new google.maps.LatLng(latitude, longitude);

                             var marker = new google.maps.Marker({

                                      position: currentLatLng,

                                      map: map,

                                      icon: {

                                                path: google.maps.SymbolPath.CIRCLE,

                                                scale: 6,

                                                strokeColor: 'black',

                                                strokeOpacity: 0.6,

                                                strokeWeight: 1.0,

                                                fillColor: markerColor,

                                                fillOpacity: 0.6

                                      }

                             });     

 

The memory gradually increase and the application hangs after some time. Is there any way to clear the memory ?