From 1fe666192b0d318b3c907db2119263cd4efa908e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 14 Nov 2012 19:53:29 +0100 Subject: fix($rootScope): workaround for Chrome's memleak Under certain circumstances chrome fails to GC scopes because of buggy optimizations and caching. Nulling out references to (not from!) other scopes helps Chrome to realize that this object should be GC-ed. This is really just a workaround as the real problem needs to be fixed in Chrome. See discusstion at: https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 And chrome bug at: https://code.google.com/p/v8/issues/detail?id=2073 Closes #1313 --- src/ng/rootScope.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index bd712e07..8c969b5e 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -476,6 +476,11 @@ function $RootScopeProvider(){ if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling; if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling; if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling; + + // This is bogus code that works around Chrome's GC leak + // see: https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 + this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = + this.$$childTail = null; }, /** -- cgit v1.2.3