Free more data on worker destruction

This commit is contained in:
Jarred Sumner
2024-07-30 23:11:04 -07:00
parent a44b7e41d2
commit e64971c0b2
3 changed files with 31 additions and 0 deletions

View File

@@ -331,6 +331,16 @@ pub const All = struct {
return JSValue.jsUndefined();
}
pub fn deinit(this: *All) void {
if (Environment.isWindows) {
this.uv_timer.stop();
}
this.maps.setImmediate.clearAndFree(bun.default_allocator);
this.maps.setTimeout.clearAndFree(bun.default_allocator);
this.maps.setInterval.clearAndFree(bun.default_allocator);
}
const Shimmer = @import("../bindings/shimmer.zig").Shimmer;
pub const shim = Shimmer("Bun", "Timer", @This());

View File

@@ -2433,6 +2433,7 @@ pub const VirtualMachine = struct {
// TODO:
pub fn deinit(this: *VirtualMachine) void {
this.timer.deinit();
this.source_mappings.deinit();
if (this.rare_data) |rare_data| {
rare_data.deinit();

View File

@@ -402,4 +402,24 @@ pub fn deinit(this: *RareData) void {
if (this.boring_ssl_engine) |engine| {
_ = bun.BoringSSL.ENGINE_free(engine);
}
if (this.stderr_store) |store| {
this.stderr_store = null;
store.deref();
}
if (this.stdout_store) |store| {
this.stdout_store = null;
store.deref();
}
if (this.stdin_store) |store| {
this.stdin_store = null;
store.deref();
}
if (this.entropy_cache) |cache| {
this.entropy_cache = null;
bun.default_allocator.destroy(cache);
}
}