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

Memory leak when using observe #208

Closed
arosequist opened this issue Jul 17, 2018 · 2 comments · Fixed by #212
Closed

Memory leak when using observe #208

arosequist opened this issue Jul 17, 2018 · 2 comments · Fixed by #212
Assignees

Comments

@arosequist
Copy link
Contributor

Runnable example

If you observe an object, I think it stays in memory after all references to it are gone (even if you unobserve it).

I'm not certain, but I suspect that the beforeDict is what's holding on to it. When the observer is created, we push onto the array, but we never splice it out.

It would be great if we could use weak references in that array, but I don't think that's possible in JavaScript. Can we just splice it in the unobserve function?

@alshakero
Copy link
Collaborator

Hi! Thanks for reporting this.

It would be great if we could use weak references in that array

It is certainaly possible but this library was build before WeakMaps were around. Now even IE11 supports them.

I'll look into this sometime soon.

@alshakero
Copy link
Collaborator

PR in #212

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 a pull request may close this issue.

2 participants