From f6f744aea172e9c371663ac0a5a7bba93eb5c63d Mon Sep 17 00:00:00 2001 From: sjorsdonkers <72333389+sjorsdonkers@users.noreply.github.com> Date: Fri, 2 May 2025 15:06:21 +0200 Subject: [PATCH] Fix gc_hints not being send --- src/runtime/js.zig | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/runtime/js.zig b/src/runtime/js.zig index f501eac6..85761058 100644 --- a/src/runtime/js.zig +++ b/src/runtime/js.zig @@ -301,22 +301,21 @@ pub fn Env(comptime S: type, comptime types: anytype) type { // no init, must be initialized via env.newExecutor() pub fn deinit(self: *Executor) void { - if (self.scope) |scope| { - const isolate = scope.isolate; + if (self.scope != null) { self.endScope(); + } - // V8 doesn't immediately free memory associated with - // a Context, it's managed by the garbage collector. So, when the - // `gc_hints` option is enabled, we'll use the `lowMemoryNotification` - // 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; - v8.HandleScope.init(&handle_scope, isolate); - defer handle_scope.deinit(); + // V8 doesn't immediately free memory associated with + // a Context, it's managed by the garbage collector. So, when the + // `gc_hints` option is enabled, we'll use the `lowMemoryNotification` + // 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; + v8.HandleScope.init(&handle_scope, self.env.isolate); + defer handle_scope.deinit(); - self.env.isolate.lowMemoryNotification(); - } + self.env.isolate.lowMemoryNotification(); // TODO we only need to call this for the main World Executor } self.call_arena.deinit(); self.scope_arena.deinit();