deno
b31680f5 - fix(runtime): reduce memory retention after web worker termination (#32617)

Commit
180 days ago
fix(runtime): reduce memory retention after web worker termination (#32617) ## Summary Addresses #26058 — Web Workers use significantly more RSS than Chrome, and terminating them doesn't release the memory back to the OS. Two targeted changes: - **Call `malloc_trim(0)` on Linux after each worker thread exits.** When a worker's V8 isolate and tokio runtime are dropped, glibc's allocator holds onto the fragmented heap pages rather than returning them to the OS. This explicitly asks glibc to release them. Follows the same pattern already used in the SIGUSR2 memory trim handler (`runtime/worker.rs:81`). - **Remove the delayed termination hack entirely.** The 2-second timer that spawned threads/tasks to force-terminate workers is no longer needed — the upstream V8 issue that required it has been fixed. Workers now terminate cooperatively via the termination signal and event loop wakeup, which also eliminates the ~100 lingering OS threads during rapid worker churn. ### What this doesn't fix - The ~7-8MB per-isolate overhead from V8's lack of shared read-only heap (upstream V8 issue) - macOS/Windows RSS behavior (`malloc_trim` is Linux-only) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Author
Parents
Loading