Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(change-detection): remove memory leak
Browse files Browse the repository at this point in the history
When the change detection finds change it creates a
linked list of records which have changed. The linked
list is not bound to groups but rather crosses groups, 
this implies that if we remove a group it is possible that
a record in a live group retains a pointer to a 
record in the now deleted record. While technically
not a leak, the memory will not be realized until that
record detects another change and gets re-added to the
dirty list. If the record never fires than the
memory is retained forever.
  • Loading branch information
mhevery committed Mar 5, 2014
1 parent a0df40a commit 847af41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/change_detection/watch_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ class RootWatchGroup extends WatchGroup {
} catch (e, s) {
if (exceptionHandler == null) rethrow; else exceptionHandler(e, s);
}
dirtyWatch = dirtyWatch._nextDirtyWatch;
var nextDirtyWatch = dirtyWatch._nextDirtyWatch;
dirtyWatch._nextDirtyWatch = null;
dirtyWatch = nextDirtyWatch;
}
_dirtyWatchHead = _dirtyWatchTail = null;
if (processStopwatch != null) processStopwatch..stop()..increment(count);
Expand Down
3 changes: 3 additions & 0 deletions lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class RootScope extends Scope {
}
_runAsyncHead = _runAsyncHead._next;
}
_runAsyncTail = null;

digestTTL--;
count = rootWatchGroup.detectChanges(
Expand Down Expand Up @@ -498,6 +499,7 @@ class RootScope extends Scope {
}
_domWriteHead = _domWriteHead._next;
}
_domWriteTail = null;
if (runObservers) {
runObservers = false;
observeGroup.detectChanges(exceptionHandler:_exceptionHandler);
Expand All @@ -510,6 +512,7 @@ class RootScope extends Scope {
}
_domReadHead = _domReadHead._next;
}
_domReadTail = null;
} while (_domWriteHead != null || _domReadHead != null);
assert((() {
var watchLog = [];
Expand Down

0 comments on commit 847af41

Please sign in to comment.