mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
add comments about the cause of the leak
This commit is contained in:
parent
fca9d95519
commit
eea4a02ef5
1 changed files with 6 additions and 0 deletions
|
@ -7,6 +7,8 @@ use std::cell::{Cell, UnsafeCell};
|
||||||
pub(crate) struct BumpFrame {
|
pub(crate) struct BumpFrame {
|
||||||
pub bump: UnsafeCell<Bump>,
|
pub bump: UnsafeCell<Bump>,
|
||||||
pub node: Cell<*const RenderReturn<'static>>,
|
pub node: Cell<*const RenderReturn<'static>>,
|
||||||
|
|
||||||
|
// The bump allocator will not call the destructor of the objects it allocated. Attributes and props need to have there destructor called, so we keep a list of them to drop before the bump allocator is reset.
|
||||||
pub(crate) attributes_to_drop_before_reset: RefCell<Vec<*const Attribute<'static>>>,
|
pub(crate) attributes_to_drop_before_reset: RefCell<Vec<*const Attribute<'static>>>,
|
||||||
pub(crate) props_to_drop_before_reset: RefCell<Vec<*const VComponent<'static>>>,
|
pub(crate) props_to_drop_before_reset: RefCell<Vec<*const VComponent<'static>>>,
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,10 @@ impl BumpFrame {
|
||||||
.push(attribute);
|
.push(attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reset the bump allocator and drop all the attributes and props that were allocated in it.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
/// The caller must insure that no reference to anything allocated in the bump allocator is available after this function is called.
|
||||||
pub(crate) unsafe fn reset(&self) {
|
pub(crate) unsafe fn reset(&self) {
|
||||||
let mut attributes = self.attributes_to_drop_before_reset.borrow_mut();
|
let mut attributes = self.attributes_to_drop_before_reset.borrow_mut();
|
||||||
attributes.drain(..).for_each(|attribute| {
|
attributes.drain(..).for_each(|attribute| {
|
||||||
|
|
Loading…
Reference in a new issue