Explorar o código

fix memory leak

Evan Almloff %!s(int64=2) %!d(string=hai) anos
pai
achega
77381ceadd
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      packages/native-core/src/real_dom.rs

+ 4 - 0
packages/native-core/src/real_dom.rs

@@ -76,6 +76,10 @@ impl<S: State> RealDom<S> {
         if self.node_id_mapping.len() <= element_id.0 {
             self.node_id_mapping.resize(element_id.0 + 1, None);
         }
+        if let Some(Some(old_id)) = self.node_id_mapping.get(element_id.0) {
+            // free the memory associated with the old node
+            self.tree.remove(*old_id);
+        }
         self.node_id_mapping[element_id.0] = Some(node_id);
     }