fix: fix leaks in memos, and in scope parent tracking (#841)

This commit is contained in:
Nova 2023-04-09 15:36:53 -05:00 committed by GitHub
parent 4e1f963750
commit 70f3edb0f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -1,8 +1,9 @@
#![forbid(unsafe_code)]
use crate::{
create_effect, diagnostics::AccessDiagnostics, node::NodeId, on_cleanup,
with_runtime, AnyComputation, RuntimeId, Scope, SignalDispose, SignalGet,
SignalGetUntracked, SignalStream, SignalWith, SignalWithUntracked,
with_runtime, AnyComputation, RuntimeId, Scope, ScopeProperty,
SignalDispose, SignalGet, SignalGetUntracked, SignalStream, SignalWith,
SignalWithUntracked,
};
use cfg_if::cfg_if;
use std::{any::Any, cell::RefCell, fmt::Debug, marker::PhantomData, rc::Rc};
@ -80,7 +81,9 @@ pub fn create_memo<T>(
where
T: PartialEq + 'static,
{
cx.runtime.create_memo(f)
let memo = cx.runtime.create_memo(f);
cx.push_scope_property(ScopeProperty::Effect(memo.id));
memo
}
/// An efficient derived reactive value based on other reactive values.

View file

@ -254,6 +254,8 @@ impl Scope {
}
}
runtime.scope_parents.borrow_mut().remove(self.id);
// remove everything we own and run cleanups
let owned = {
let owned = runtime.scopes.borrow_mut().remove(self.id);