Skip to content

Conversation

@sjorsdonkers
Copy link
Contributor

  • Fixes some locals that were leaking onto the global scope

inline for (Types, 0..) |s, i| {
templates[i] = generateClass(@field(types, s.name), isolate);
@setEvalBranchQuota(10_000);
templates[i] = v8.Persistent(v8.FunctionTemplate).init(isolate, generateClass(@field(types, s.name), isolate)).castToFunctionTemplate();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you not freeing these in deinit because you figure the isolate is going away anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

// call on the isolate to encourage v8 to free any contexts which
// have been freed.
if (self.env.gc_hints) {
var handle_scope: v8.HandleScope = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to create a HandleScope to free memory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it crashes otherwise with the HandleScope message. Anything that creates a local requires a scope to be active. Before this was leaking the object into the global scope.

@sjorsdonkers sjorsdonkers marked this pull request as ready for review April 29, 2025 13:05
@karlseguin karlseguin merged commit e22ec72 into scope_tightening Apr 29, 2025
18 of 19 checks passed
@karlseguin karlseguin deleted the scope_tightening_no_global_scope branch April 29, 2025 13:07
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants