From bd524fc4e5fc0feffe85632a7a6560da6bd9b762 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 14 Nov 2012 19:53:29 +0100 Subject: [PATCH] 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(+) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 759b4c7291a7..5754ad32c3f7 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; }, /**