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

Commit

Permalink
fix($rootScope): stop memory leak in IE9
Browse files Browse the repository at this point in the history
DO NOT MERGE
This is a work in progress for discussion - it is not ideal is lacking tests.

Closes #10706
  • Loading branch information
petebacondarwin committed May 1, 2015
1 parent dfa722a commit 7374515
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ function $RootScopeProvider() {
$event.currentScope.$$destroyed = true;
}

function cleanUpScope($scope) {
// Recurse bottom up
$scope.$$childHead && cleanUpScope($scope.$$childHead);
$scope.$$nextSibling && cleanUpScope($scope.$$nextSibling);

$scope.$$nextSibling = $scope.$$prevSibling = $scope.$$childHead =
$scope.$$childTail = $scope.$root = $scope.$$watchers = null;
}

/**
* @ngdoc type
* @name $rootScope.Scope
Expand Down Expand Up @@ -900,6 +909,13 @@ function $RootScopeProvider() {
this.$on = this.$watch = this.$watchGroup = function() { return noop; };
this.$$listeners = {};

var that = this;
if (msie === 9) {
this.$evalAsync(function() {
cleanUpScope(that);
});
}

// All of the code below is bogus code that works around V8's memory leak via optimized code
// and inline caches.
//
Expand Down

0 comments on commit 7374515

Please sign in to comment.