I have the following issue. I am removing all references to a google maps instance including markers via the setMap(null)
option via the following code:
This is a known issue in Google Maps API v3 - even pure creation and destruction of google.maps
object (no marker creation) results in memory leak. See Issue 3803: Bug: Destroying Google Map Instance Never Frees Memory.
They reproduce the issue by creating a simple loop that creates and destroys the google.maps
object. See
http://jsfiddle.net/KWf4r/
After pressing start, you will observe your browser to grow in memory until you press stop.
The issue is not fixed and there doesn't seem to be an official workaround available. There is certainly a way, but it's not a clean workaround that apparently might stop working in next release of google maps api - citing the discussion:
I've actually managed to find a semi-workable fix by manually destroying a lot of the elements that google maps creates (and removing listeners). However, I am using a lot of undocumented things to do this (I had to check in the chrome inspector to see what to try to remove), so this doesn't seem the right way to go.