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

Suggest using weak references #474

Open
jakearchibald opened this issue Jun 20, 2021 · 1 comment
Open

Suggest using weak references #474

jakearchibald opened this issue Jun 20, 2021 · 1 comment

Comments

@jakearchibald
Copy link
Contributor

Mutation observers suggest that they have a weak reference to observed elements, so if the element is otherwise garbage collected, then the observer is also collected. This seems to work in practice.

However, with similar code, IntersectionObserver leaks memory. The same happens with ResizeObserver.

https://bugs.chromium.org/p/chromium/issues/detail?id=1220041 (includes demos) - the same issue effects Firefox and Safari.

The IntersectionObserver spec should suggest that observed elements are weakly referenced, similar to MutationObserver.

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

No branches or pull requests

1 participant