-
-
Notifications
You must be signed in to change notification settings - Fork 990
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/Detached DOM nodes when node is removed #3760
Comments
Does adding a |
Does that mean wrapping it with a 'Fragment'? I'm AFK right now, but if that's what you mean, I don't think it makes a difference. I use 'Fragment' in my original code and it has same problem. I don't know if I'm barking up the wrong tree here but I think it's a node deletion problem because I see detached nodes from other parts of the DOM popping up outside the list as well. I saw some of the logic explicitly wants to keep some state around so maybe it's some combo of trying to reuse elements while adding and deleting same time |
I mean: rsx! {
for (i, item) in vec_signal.into_iter().enumerate() {
Child { key: "{i}", item }
}
} |
Ah I didn't know that's possible - but no, it doesn't help |
This comment has been minimized.
This comment has been minimized.
The dioxus interpreter uses a slot map to store element references. The slots should automatically get reused over time and clear the old references as new nodes are allocated. If they are not getting cleared, this is probably a bug in dioxus core |
Just kidding, the new example code is not bad. The number of detached nodes does grow, but they eventually get garbage collected. I'll try isolate under what conditions GC fails to clean up the nodes. |
I believe the problem ultimately boils down to https://github.com/DioxusLabs/dioxus/blob/bdeedc13eb504d3e05edb48575ceda52aea09eff/packages/core/src/diff/node.rs#L335C8-L335C31 calling |
Problem
Rendering a
Signal<Vec<T>>
with something like the following causes unbounded DOM node growth when theVec<T>
can change length up and down between renders. It creates a bunch of detached nodes as can be seen in the image.Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
Nodes should drop without hanging around in a detached state
Screenshots
Environment:
The text was updated successfully, but these errors were encountered: