Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix v8::OwnedIsolate memory leak caused by retain cycle in MiniV8::create_function #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlaaAlHallaq
Copy link

The only way to test this at least for my current expertise in Rust :

  • is by adding a print statement in drop impl for OwnedIsolate or a break point.
    the following example:
    let ctx = MiniV8::new();
    let obj = ctx.create_object();
    let fc = ctx.create_function(|env| {
        let me = env
            .this
            .as_object()
            .ok_or(mini_v8::Error::FromJsConversionError {
                from: "value",
                to: "object",
            })?;
        let v: Value = me.get("name")?;
        return Ok(v);
    });
    obj.set("name", "jack").unwrap();
    obj.set("getName", fc).unwrap();
    ctx.global().set("person", obj).unwrap();
    let returned_name: String = ctx.eval("person.getName()").unwrap();
    println!("person.getName() = {:?}", returned_name);
    drop(ctx);

before this apply this pr nether the print statement nor the break point will be reached & v8::OwnedIsolate wont be dropped.
after applying it, it just works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant