Explorar o código

fix memory leak

Evan Almloff %!s(int64=2) %!d(string=hai) anos
pai
achega
00a9ad29a8
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  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 {