浏览代码

fix memory leak

Evan Almloff 2 年之前
父节点
当前提交
00a9ad29a8
共有 1 个文件被更改,包括 9 次插入0 次删除
  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 {