Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7374515

Browse files
fix($rootScope): stop memory leak in IE9
DO NOT MERGE This is a work in progress for discussion - it is not ideal is lacking tests. Closes #10706
1 parent dfa722a commit 7374515

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ng/rootScope.js

+16
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ function $RootScopeProvider() {
101101
$event.currentScope.$$destroyed = true;
102102
}
103103

104+
function cleanUpScope($scope) {
105+
// Recurse bottom up
106+
$scope.$$childHead && cleanUpScope($scope.$$childHead);
107+
$scope.$$nextSibling && cleanUpScope($scope.$$nextSibling);
108+
109+
$scope.$$nextSibling = $scope.$$prevSibling = $scope.$$childHead =
110+
$scope.$$childTail = $scope.$root = $scope.$$watchers = null;
111+
}
112+
104113
/**
105114
* @ngdoc type
106115
* @name $rootScope.Scope
@@ -900,6 +909,13 @@ function $RootScopeProvider() {
900909
this.$on = this.$watch = this.$watchGroup = function() { return noop; };
901910
this.$$listeners = {};
902911

912+
var that = this;
913+
if (msie === 9) {
914+
this.$evalAsync(function() {
915+
cleanUpScope(that);
916+
});
917+
}
918+
903919
// All of the code below is bogus code that works around V8's memory leak via optimized code
904920
// and inline caches.
905921
//

0 commit comments

Comments
 (0)