Jelajahi Sumber

fix memory leak

Evan Almloff 2 tahun lalu
induk
melakukan
00a9ad29a8
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      packages/core/src/scopes.rs

+ 9 - 0
packages/core/src/scopes.rs

@@ -73,6 +73,15 @@ pub(crate) struct ScopeSlab {
     entries: Slab<Slot<'static, ScopeState>>,
 }
 
+impl Drop for ScopeSlab {
+    fn drop(&mut self) {
+        // Bump slab doesn't drop its contents, so we need to do it manually
+        for slot in self.entries.drain() {
+            self.slab.remove(slot);
+        }
+    }
+}
+
 impl Default for ScopeSlab {
     fn default() -> Self {
         Self {