diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 82d58e4592ac396bd1623f1b572d6706c46427d4..eed48e79adfa839ebdcd395c297ae1f47761c6a1 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -1410,12 +1410,13 @@ fn workerMakeOneStep( if (s.max_rss != 0) { var dispatch_deps: std.ArrayList(*Step) = .empty; defer dispatch_deps.deinit(gpa); - dispatch_deps.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len) catch @panic("OOM"); { run.max_rss_mutex.lockUncancelable(io); defer run.max_rss_mutex.unlock(io); + dispatch_deps.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len) catch @panic("OOM"); + // Give the memory back to the scheduler. run.claimed_rss -= s.max_rss; // Avoid kicking off too many tasks that we already know will not have