I would highly suggest that instead of removing and re-adding the
poly, or manually setting the path, you instead make the initial path
array an MVCArray. Then as you change the points in the array, the
polygon will automatically update.

See 
http://code.google.com/apis/maps/documentation/javascript/reference.html#MVCArray

Chad Killingsworth

On Dec 1, 4:42 pm, John Mick <[email protected]> wrote:
> I am the developer of an existing Maps V2 (and GEE) application that
> displays Polygonal data in real-time, updating every 25 seconds. V2's
> GPolygon Objects would leak browser memory (that would never be
> retained) so I ultimately was forced to write my own custom proprietary
> library to meet the needs of updating SVG Polygons every 25 seconds
> without dealing with browser memory leaks.
>
> Now that V3 has been around for awhile I am starting the process of
> migrating my application over to V3 and was hoping that the new Polygon
> objects would have alleviated this problem : I've noticed that they
> have changed quite a bit.
>
> I devised three different methods to update an existing Polygon object
> when new data arrives:
>
> - Method 1 - Using the "setPaths" function
> - poly.setPaths(newMultiDimensionalArrayOfLatLngs)
> - Method 2 - Setting the Polygon's Map to Null, then assigning the old
> Polygon object to a new Polygon, then finally adding it to the map
> - poly.setMap(null)
> - poly = new google.maps.Polygon({options})
> - poly.setMap(map)
> - This method causes the Polygon Object to Visibly "Flicker" as it is
> removed and recreated on the map and is not really desirable
> - Method 3 - Setting the "paths" option to a new multi-dimensional
> array of LatLngs
> - poly.setOptions({paths:newMultiDimensionalArrayOfLatLngs})
> I started testing these three methods yesterday on a Windows 7 64 bit
> machine with IE8, Chrome 7.0.517.44, and Firefox 3.6.12. Unfortunately
> in every browser it appears that a memory leak is occurring.
>
> Both Firefox and Chrome will allow their memory consumption to rise for
> a period of time then, I'm presuming, the JS Garbage Collector comes
> around and cleans up lowering the memory usage in the browser process
> back down to a level close to where it was initially, however it isn't
> the same - so after a period of a few hours there is a very apparent
> leak.
>
> Internet Explorer 8's leak is much easier to identify - as the memory
> usage will constantly increase into the hundreds of MBs until the
> browser is closed.
>
> I have made my test applications available to the public here:
>
> - Method 1
>
> - Method 2
>
> - Method 3
> The source code is easily readable as well. I'm posting my findings
> here because I'm hoping that perhaps somebody has some experience with
> this, specifically with V3 Polygons, and could point out something
> simple that I am doing incorrectly to cause the leak. Otherwise I am
> going to revert back to using the library I already have - but I was
> really hoping to migrate over to the Google API for Polygons.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to