-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngAnimate: memory leak in disabledElementsLookup Map #16637
Comments
If we only had WeakMaps 😃 I am not sure, but I guess the reason for choosing a map over storing the value on the DOM element itself was speed. Since we only set a value when calling (Note to self: This should be independent of Listening for the element's |
You are right about trying to tap into weird environments ($destroy, .data() etc). Then it would be something that must be explicitly called, eg:
|
For the record, I said listening for the element's Let's see what others think. (Cc @Narretz who has more experience with |
aha, I misunderstood what you meant (exhaustion :D) |
I would probably go with the event listener. I assume that setting on the node directly is pretty slow on older IEs. |
Note that adding an event listener also assigns stuff on the node under the hood 😁 @vertazzar, would you be interested in taking a stub at fixing this? |
Easiest solution was just to write something like:
the .data() is to avoid constant listener registration when running the For the element lifecycle I'm not sure if the value of |
…led)` When disabling/enabling animations on a specific element (via `$animate.enabled(element, enabled)`), the element is added in a map to track its state. Previously, the element was never removed from the map, causing AngularJS to hold on to the element even after it is removed from the DOM, thus preventing it from being garbage collected. This commit fixes it by removing the element from the map on `$destroy`. Fixes angular#16637.
As mentioned in #16637 (comment), the scope's I created a PR that bind to the element's |
…led)` When disabling/enabling animations on a specific element (via `$animate.enabled(element, enabled)`), the element is added in a map to track its state. Previously, the element was never removed from the map, causing AngularJS to hold on to the element even after it is removed from the DOM, thus preventing it from being garbage collected. This commit fixes it by removing the element from the map on `$destroy`. Fixes #16637. Closes #16649
All begins with this line of the code:
angular.js/src/ngAnimate/animateQueue.js
Line 306 in 494277e
Reproducable: always
Browsers: Any
Operating system: Any
Versions: All that use the hash map
Steps to reproduce:
Available in codepen: https://codepen.io/anon/pen/yqVwwE
click on "leaker" n times to get n detached nodes as seen in the screenshot
Solution: listen for element scope destroy event, or
element.on('remove')
and delete the node fromdisabledElementsLookup
Map ?Note: If this is "working as intended" at least provide public api to
disabledElementsLookup
so we can cleanup after directive exitsThe text was updated successfully, but these errors were encountered: