allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 517 forks source link

Possible memory leak in NgMap itself? #822

Open jlynde opened 7 years ago

jlynde commented 7 years ago

There may be a memory leak in the NgMap code itself. I realize that Google Maps has a memory leak and this may or may not be related so I am submitting this to be sure one way or the other.

Steps to reproduce:

Load the Plnkr from here: http://plnkr.co/ZNQN4c

Switch back and forth between Page-1 and Page-2 a couple of times Finish up on Page-1 to start at a particular state

Bring up Chrome Dev tools, Memory tab With the "Take Heap Snapshot" radio button selected, Click Take Snapshot

When that finishes, click Page-2 When that has loaded fully, Click the Red "Take heap snapshot" button on the memory tab again

When that finishes, click Page-1 again When that has loaded fully, Click the Red "Take heap snapshot" button on the memory tab one last time

Now in the memory tab the third snapshot "Snapshot 3" should be selected. At the top of the next column, change the "All objects" dropdown to "All objects allocated between Snapshot 1 and Snapshot 2" Then type "scw" in the filter input field just to the left of that dropdown to isolate the controller from myMap.js Expand the first level of ScwMapController and select the second one (with the "@#######" next to it)

The window below will show the "Retainers" for the variable __tag (from the myMap.js controller)

Following the retainers chain you can see that the controller is being retained by the ng-map hideInfoWindow function

Do you know why this is happening? This is more than just the Google Maps leak. It appears that NgMap is also leaking here. Can you take a look?

If you use the Memory tab and the "Record Allocation Timeline" feature and load Page-2 several times you can see that each time it is loaded the controller is leaked in the same way.

I appreciate any insights you can provide into this issue.

Thanks, John