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

[BUGFIX release] Clear chains in ProxyMixin when destroyed #16860

Merged
merged 2 commits into from Sep 5, 2018

Conversation

pieter-v
Copy link
Contributor

@pieter-v pieter-v commented Aug 3, 2018

When a ObjectProxy is destroyed while the proxied object is still alive, then the ObjectProxy is leaked because the chains attached to the proxied object retains the ObjectProxy.
This is an issue for us, as ember-data uses proxies for their belongsTo relationships. (See emberjs/data#5554 for more information)

A sample program that demonstrates this can be found at https://github.com/pieter-v/ember-proxy-leak

A memory snapshot before this fix:
before

A memory snapshot after this fix:
after

@@ -61,6 +61,11 @@ export default Mixin.create({
m.writableTag(() => combine([DirtyableTag.create(), UpdatableTag.create(CONSTANT_TAG)]));
},

destroy() {
this._super(...arguments);
this.set('content', null);
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to set the content before supering. Do you see any issues with that?

@pieter-v
Copy link
Contributor Author

pieter-v commented Aug 3, 2018 via email

@rwjblue
Copy link
Member

rwjblue commented Aug 3, 2018 via email

Copy link
Member

@krisselden krisselden left a comment

Choose a reason for hiding this comment

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

destroy should use ember set only willDestroy, destroy is only supposed to mark is destroying and schedule willDestroy which can set

@rwjblue
Copy link
Member

rwjblue commented Sep 4, 2018

Sorry for the delays, the repo reorganization has caused conflicts here would you mind rebasing?

@pieter-v
Copy link
Contributor Author

pieter-v commented Sep 5, 2018

rebased

@rwjblue rwjblue changed the title [BUGFIX] Clear chains in ProxyMixin when destroyed [BUGFIX release] Clear chains in ProxyMixin when destroyed Sep 5, 2018
@rwjblue rwjblue merged commit fa43958 into emberjs:master Sep 5, 2018
@pieter-v pieter-v deleted the proxy-leak branch May 18, 2020 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants