Skip to content

Svelte 5 memory leak after transitions #12719

Closed
@gyzerok

Description

@gyzerok

Describe the bug

Transitions in Svelte 5 causes memory leaks by holding onto the DOM nodes indefinitely.

image

Also I found this PR which seems to be fixing a similar problem back in 2022 and this issue, that reports something similar for version 4.

In our case we are writing highly interactive real-time SPA, which means that user will go between screens a lot and will keep tab open for days, which gets amount of detached nodes to hundreds of thousands or maybe even millions. I can get from 1k to 20k nodes in a minute.

Reproduction

Here is the repo with the smallest example: https://github.com/gyzerok/svelte-transition-memory-leak.

Clone the repo and npm i && npm run dev.

Steps:

  1. Open app in Chrome
  2. Record memory snapshot
  3. Click button twice
  4. Record second memory snapshot
  5. Compare both snapshots and filter by "detached"

Logs

No response

System Info

Chrome 127.0.6533.89

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions