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

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:
#1313 (comment)

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

Closes #1313
  • Loading branch information
IgorMinar committed Nov 14, 2012
1 parent 19a324c commit bd524fc
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

1 comment on commit bd524fc

@IgorMinar
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note that this commit causes NPEs when a scope is destroyed more than once. the issue was fixed in d6da505

Please sign in to comment.