Skip to content

Key+each blocks leaking memory in legacy mode #16040

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

Open
lassebomh opened this issue May 30, 2025 · 0 comments
Open

Key+each blocks leaking memory in legacy mode #16040

lassebomh opened this issue May 30, 2025 · 0 comments
Labels
p0 stuff we should fix ASAP
Milestone

Comments

@lassebomh
Copy link

Describe the bug

At my company we experienced tabs crashing due to running out of memory. The root cause is somewhere in svelte, and I was able to create a minimal reproducible example. The memory usage looks like this (over 40 seconds):

Image

Reproduction

<script>
  const array = new Array(1000)
  let x = 0
  setInterval(() => x++, 10)
</script>

{#key x}
  {#each array as _}{/each}
{/key}

I have a repo here https://github.com/lassebomh/svelte-leak just in case. Its just the default project from pnpm create vite@latest . with unecessary stuff removed and the above code in App.svelte.

Run the project and open the memory devtools tab. Watch this number:

Image

If x is wrapped in a $state then the memory usage looks like this, leading me to believe it's a legacy only issue:

Image

Logs

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 9 6900HS with Radeon Graphics        
    Memory: 14.66 GB / 31.25 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.3 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (134.0.3124.72)
    Internet Explorer: 11.0.26100.1882

Severity

annoyance

@Rich-Harris Rich-Harris added this to the 5.x milestone Jun 2, 2025
@Rich-Harris Rich-Harris added the p0 stuff we should fix ASAP label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p0 stuff we should fix ASAP
Projects
None yet
Development

No branches or pull requests

2 participants