Skip to content

Fix memory leak when passing mapped stores as component props - #5711

Merged
jkelleyrtp merged 1 commit into
mainfrom
devin/1785172501-store-prop-leak
Jul 29, 2026
Merged

Fix memory leak when passing mapped stores as component props#5711
jkelleyrtp merged 1 commit into
mainfrom
devin/1785172501-store-prop-leak

Conversation

@ealmloff

@ealmloff ealmloff commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the unbounded memory growth in #5671.

Store-typed props (Store/ReadStore/WriteStore) get auto_into = true in the props macro, so a mapped store (e.g. an item from store.iter()) passed as a Store<T> prop is converted via From<MappedStore> for WriteStore, which boxes the lens with WriteSignal::new_maybe_syncCopyValue::new_maybe_sync. Because store types were missing from child_owned_type, that conversion ran in the parent scope's owner: since CopyValue has no Drop, each rerender of the parent leaked one boxed lens per store prop until the parent scope was dropped. In the issue's repro (100 items rerendered on every pointermove), that's ~17 KB leaked per render.

The fix adds looks_like_store_type to child_owned_type, so store prop conversions run inside with_owner(props.owner, …) — the same mechanism already used for ReadSignal/WriteSignal/callback props — and the boxed lens is freed when the props are dropped.

Verified with a counting-allocator harness running the issue's example for 1000 rerenders: heap delta goes from ~17 MB (growing linearly) to flat.

Note: store props still don't participate in the point_to/mark_dirty memoization that signal_fields get in memoize_impl; that's a separate (non-leaking) issue.

Fixes #5671

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/671e48ef36ad4dde9bf93eafa654c32c
Requested by: @ealmloff


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Co-Authored-By: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com>
@ealmloff
ealmloff requested a review from a team as a code owner July 27, 2026 17:15
@ealmloff ealmloff self-assigned this Jul 27, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@jkelleyrtp
jkelleyrtp merged commit e0410a4 into main Jul 29, 2026
21 of 37 checks passed
@jkelleyrtp
jkelleyrtp deleted the devin/1785172501-store-prop-leak branch July 29, 2026 03:08
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.

Memory leak

2 participants