Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map objects persist in memory after component is detached #425

Open
KeithHenry opened this issue Jun 25, 2018 · 0 comments
Open

Map objects persist in memory after component is detached #425

KeithHenry opened this issue Jun 25, 2018 · 0 comments

Comments

@KeithHenry
Copy link

This is a known issue in the API: https://issuetracker.google.com/issues/35821412 - it's been extant since 2011, so a fix is unlikely.

Every time new google.maps.Map(... is called on a new DOM element it adds a load of window and global event listeners. When the holding element is removed from the DOM the global events keep the map in memory.

This isn't a problem in traditional web apps, as the events are reset on the next page load, but in an SPA or PWA you get a stack of old maps in memory that are all listening for window resize and keydown events.

There appear to be two approaches to working around this:

  • Maintain a singleton map/s DOM element that are reset and reused.
  • Remove all the events on detach.

While the latter is preferred, it doesn't seem possible without digging through the internal implementation of the maps API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant