Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed memory leak of previousContents when tracking array changes and disposing the subscription #2217

Merged

Conversation

decden
Copy link
Contributor

@decden decden commented Mar 29, 2017

The observableArray did leak the last value held by the observable when
subscribing for array change events, and then disposing the subscription.

The vlaue was being held by the closure held by the
arrayChangeSubscription. Setting it to null allows the GC to collect the
closure and the previousContents variable.

This commit fixes #2216

The observableArray did leak the last value held by the observable when
subscribing for array change events, and then disposing the subscription.

The vlaue was being held by the closure held by the
arrayChangeSubscription. Setting it to null allows the GC to collect the
closure and the previousContents variable.

This commit fixes knockout#2216
@mbest
Copy link
Member

mbest commented Mar 29, 2017

Looks good. Thanks.

@codymullins
Copy link

I must be one of the few that shudder at if statements without brackets ;-)

@mbest
Copy link
Member

mbest commented Mar 31, 2017

@codymullins Knockout is inconsistent regarding braces, but I've been trying to make sure all new code uses them. @decden Can you add the braces?

@mbest mbest merged commit 0ee72ac into knockout:master Apr 8, 2017
brianmhunt added a commit to knockout/tko.observable that referenced this pull request Apr 8, 2017
brianmhunt added a commit to knockout/tko that referenced this pull request Apr 8, 2017
brianmhunt added a commit to knockout/tko that referenced this pull request May 8, 2017
@decden decden deleted the 2216-observable-array-leaks-last-value branch October 11, 2017 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Observable array leak last value when subscribing with 'arrayChange' and calling dispose.
3 participants