@@ -101,6 +101,29 @@ function $RootScopeProvider() {
101
101
$event . currentScope . $$destroyed = true ;
102
102
}
103
103
104
+ function cleanUpScope ( $scope ) {
105
+
106
+ if ( msie === 9 ) {
107
+ // There is a memory leak in IE9 if all child scopes are not disconnected
108
+ // completely when a scope is destroyed. So this code will recurse up through
109
+ // all this scopes children
110
+ //
111
+ // See issue https://github.com/angular/angular.js/issues/10706
112
+ $scope . $$childHead && cleanUpScope ( $scope . $$childHead ) ;
113
+ $scope . $$nextSibling && cleanUpScope ( $scope . $$nextSibling ) ;
114
+ }
115
+
116
+ // The code below works around IE9 and V8's memory leaks
117
+ //
118
+ // See:
119
+ // - https://code.google.com/p/v8/issues/detail?id=2073#c26
120
+ // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909
121
+ // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451
122
+
123
+ $scope . $parent = $scope . $$nextSibling = $scope . $$prevSibling = $scope . $$childHead =
124
+ $scope . $$childTail = $scope . $root = $scope . $$watchers = null ;
125
+ }
126
+
104
127
/**
105
128
* @ngdoc type
106
129
* @name $rootScope.Scope
@@ -897,16 +920,9 @@ function $RootScopeProvider() {
897
920
this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
898
921
this . $$listeners = { } ;
899
922
900
- // All of the code below is bogus code that works around V8's memory leak via optimized code
901
- // and inline caches.
902
- //
903
- // see:
904
- // - https://code.google.com/p/v8/issues/detail?id=2073#c26
905
- // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909
906
- // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451
907
-
908
- this . $parent = this . $$nextSibling = this . $$prevSibling = this . $$childHead =
909
- this . $$childTail = this . $root = this . $$watchers = null ;
923
+ // Disconnect the next sibling to prevent `cleanUpScope` destroying those too
924
+ this . $$nextSibling = null ;
925
+ cleanUpScope ( this ) ;
910
926
} ,
911
927
912
928
/**
0 commit comments