Git Product home page Git Product logo

Comments (4)

jkelleyrtp avatar jkelleyrtp commented on May 8, 2024 1

if the vec is extended when another use_hook is called, previous references will point to some invalid addrs ?

If we used references returned by vec then yes, but we use the pointer into the bump arena which is stable between vec pushes. Similar to Box::pin-ing the value and then returning the reference into the heap.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 8, 2024

Hooks get freed here:

        self.hook_arena.reset();
        self.hook_vals.get_mut().drain(..).for_each(|state| {
            let as_mut = unsafe { &mut *state };
            let boxed = unsafe { bumpalo::boxed::Box::from_raw(as_mut) };
            drop(boxed);
        });

self.hook_arena.reset();
self.hook_vals.get_mut().drain(..).for_each(|state| {
let as_mut = unsafe { &mut *state };
let boxed = unsafe { bumpalo::boxed::Box::from_raw(as_mut) };
drop(boxed);
});

If the hooks don't get freed (through a panic?) then it's a memory leak

from dioxus.

gfreezy avatar gfreezy commented on May 8, 2024

if the vec is extended when another use_hook is called, previous references will point to some invalid addrs ?

let state1 = use_hook(xxx)
...
// many use_hooks
// self.hook_vals extended
...
let staten = use_hook(xxx)

from dioxus.

gfreezy avatar gfreezy commented on May 8, 2024

Got it. I didn't look into it carefully.

                 let raw_box = unsafe { &mut **inn }; 

from dioxus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.