DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.3k stars 735 forks source link

Fix: memory leak on listeners for elements #2244

Closed jkelleyrtp closed 2 months ago

jkelleyrtp commented 2 months ago

We switched over to Copy types for EventHandlers on elements which is equivalent to calling Signal::new(). This is not necessary for elements, just for child components, and thus caused a memory leak for long-running components.

This PR adds a drop impl to VNode to manually drop listeners when the last VNodeInner is dropped. We can't add the drop impl anywhere else since VNode is the only struct in the chain that can't be destructured, making it semver compatible.

Fix: #2227