Skip to content

Commit

Permalink
fix: Remove 'leak' call when creating v8::ExternalReferences (denol…
Browse files Browse the repository at this point in the history
…and#509)

Calling `v8::ExternalReferences::new` does not take ownership of the Vec
- it internally copies the values into a new Vec. As a result, the
memory owned by the original Vec was never getting freed.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
  • Loading branch information
svix-aaron1011 and bartlomieju authored Jan 29, 2024
1 parent f399147 commit 5534917
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions core/runtime/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ pub(crate) fn external_references(

references.extend_from_slice(additional_references);

let refs = v8::ExternalReferences::new(&references);
// Leak, V8 takes ownership of the references.
std::mem::forget(references);
refs
v8::ExternalReferences::new(&references)
}

// TODO(nayeemrmn): Move to runtime and/or make `pub(crate)`.
Expand Down

0 comments on commit 5534917

Please sign in to comment.