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 on component unmount #12102

Closed
markpsiano opened this issue Jun 19, 2024 · 1 comment
Closed

Memory leak on component unmount #12102

markpsiano opened this issue Jun 19, 2024 · 1 comment

Comments

@markpsiano
Copy link
Contributor

markpsiano commented Jun 19, 2024

Describe the bug

When a component is unmounted, event listeners which were attached to document on component mount are not removed. This leads to a memory leak as there are unused event listeners leftover after components unmount.

This can be verified by using chrome devtools, and taking heap snapshots at various points throughout page navigation/components mounting and unmounting, where the number of event listeners increases over time. It can also be verified in elements -> event listeners tab in devtools, where there are an increasing number of listeners upon mounting and unmounting components.

Fix is here: #12101

I'm not sure if this is the correct way of reporting an issue (making a fix as well as issue ticket), but just wanted more visibility here. If not, feel free to close this one.

Reproduction

Call unmount() on a component, observe how document event listeners are still retained, number of event listeners in memory using chrome memory devtools will show increasing amount as components are unmounted

Logs

No response

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 75.61 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 20.13.1 - /usr/local/bin/node
    npm: 10.5.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 126.0.6478.62
    Safari: 15.3
  npmPackages:
    rollup: ^4.18.0 => 4.18.0 
    svelte: 5.0.0-next.155 => 5.0.0-next.155

Severity

annoyance

@trueadm
Copy link
Contributor

trueadm commented Jun 20, 2024

Closed with #12105. Thanks also for putting up a fix! Sorry I missed it originally – it's quite rare for someone to put up an issue and link to the fix at the same time :)

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

2 participants