Skip to content

Commit

Permalink
fix($rootScope): workaround for Chrome's memleak
Browse files Browse the repository at this point in the history
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:
angular#1313 (comment)

And chrome bug at:
https://code.google.com/p/v8/issues/detail?id=2073

Closes angular#1313
  • Loading branch information
IgorMinar committed Nov 14, 2012
1 parent 29541e7 commit 1fe6661
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

/**
Expand Down

0 comments on commit 1fe6661

Please sign in to comment.