-
Notifications
You must be signed in to change notification settings - Fork 27.5k
refactor($scope): prevent multiple calls to listener on $destroy
#9079
Conversation
304fb47
to
30a774d
Compare
$destroy
$destroy
30a774d
to
47f6d46
Compare
02dc2aa
to
fd2d6c0
Compare
I don't think this should be documented as a refactor. I think this should be a fix, since the behavior before is kind of unexpected. |
@btford the reason this is marked as a refactor is #8504 (comment) |
ah, okay. makes sense. |
@lgalfaso if I understand your comment from #9199, this should fix the ngSwitch issue too yeah? If that's the case, could we have a test which shows that the fix is working? (Yes I know there is a more general test case --- I just think it would be good to show how it's applicable to the raised issue) |
Stop an asynchronous compilation when this is performed on an already destroyed scope Closes angular#9199
Prevent isolated scopes from having listeners that get called multiple times when on `$destroy`
e21c2f5
to
7a29630
Compare
@petebacondarwin updated the patch |
OK. I have one more thing to say here :-) (Sorry this is dragging out.) It turns out that now that #9281 has landed, the second commit is enough on its own to ensure that the memory leak is resolved. The refactoring is not needed. How about we land the mem leak fix and then continue the discussion about the refactoring separately? If we accepted that double destroy is something that apps should be able to cope with then we would save more processing and memory by not wiring up all these destroy handlers on every scope. |
I think that the fix for the leak, as it is in this patch, would not fix the leak without the first patch. The patch for the leak checks if the scope it was asked to continue the compilation is marked with I am ok with still having the double destroy, but the second patch (without the first patch) would need to go up the hierarchy to know if the received scope is in a branch that was actually destroyed or not |
If you only add the "fix" commit and not the "refactor" commit to master the tests pass. Moreover the tests still pass even if you remove https://github.com/angular/angular.js/pull/9079/files#diff-a732922b631efed1b9f33a24082ae0dbR2042/. |
you are right, the test is not strong enough. Let me update it with a stronger test |
Updated the test with a stronger version that shows the leak when the double destroy patch was not present. If it looks good, then I will split this into two clean commits |
a849e26
to
56c7eb3
Compare
Stop an asynchronous compilation when this is performed on an already destroyed scope Closes angular#9199
56c7eb3
to
1598639
Compare
Updated the PR by having this in only two commits and added some comments to make it clear what is going on |
Stop an asynchronous compilation when this is performed on an already destroyed scope Closes angular#9199 Closes angular#9079 Closes angular#8504 Closes angular#9197
The Changelog says that this fix also made it into v1.2.26. So I just downloaded it from angularjs.org and didn't find this change in it... Edit: Probably because of this commit |
Ah yes, it was reverted so it should not have made it into the CHANGELOG. Sorry |
Prevent isolated scopes from having listeners that get called multiple times when on
$destroy