Skip to content

fix(interpreter): release removed subtrees and owned subscriptions - #5895

Open
kindintelligence wants to merge 2 commits into
DioxusLabs:mainfrom
kindintelligence:fix/interpreter-subtree-cleanup
Open

kindintelligence wants to merge 2 commits into
DioxusLabs:mainfrom
kindintelligence:fix/interpreter-subtree-cleanup

Conversation

@kindintelligence

@kindintelligence kindintelligence commented Oct 6, 2026 •

Copy link
Copy Markdown

Unmounting a component removes its DOM from the page, but the interpreter can retain descendant nodes, event listeners and observer registrations. Repeated mount/unmount cycles accumulate these references and grow memory usage.

This patch clears removed subtree bindings and subscriptions while preserving template prototypes and moved nodes. It also prevents stale mounted callbacks when node IDs are reused.

Targets Dioxus 0.8 alpha. Verified with 48 cleanup tests across Chromium and WebKit, plus Wasm and hydration checks.

@kindintelligence
kindintelligence requested a review from a team as a code owner October 6, 2026 04:37
@kindintelligence
kindintelligence marked this pull request as draft October 6, 2026 04:38
@kindintelligence
kindintelligence force-pushed the fix/interpreter-subtree-cleanup branch from 6a0937e to a8461dc Compare October 6, 2026 04:48
@kindintelligence
kindintelligence changed the base branch from v0.7 to main October 6, 2026 04:48
@kindintelligence
kindintelligence marked this pull request as ready for review October 6, 2026 04:48

@LucaCappelletti94 LucaCappelletti94 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Premising that the retireSubtree approach seems okay and the leak is indeed real, at its current size the PR is pretty hard to review.

This PR in my opinion can be at least split in 3 parts, along the following seams:

  • The subtree cleanup in core.ts
  • The mounted queue from WebsysDom into the interpreter
  • The suspense-carousel.spec.js rewrite, which fixes a flaky test which I believe is unrelated to the leak.

For the tests, a few cases added to the existing packages/playwright-tests suite would cover the regression without a second Playwright config, avoiding most of the bloat.

This branch has not been deployed

No deployments
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 this pull request may close these issues.

2 participants