Skip to content

fix: reclaim isolate host RSS on oneshot user-worker retirement - #722

Open
samvallad33 wants to merge 1 commit into
supabase:mainfrom
samvallad33:fix/edge-runtime-719-retire-rss
Open

fix: reclaim isolate host RSS on oneshot user-worker retirement#722
samvallad33 wants to merge 1 commit into
supabase:mainfrom
samvallad33:fix/edge-runtime-719-retire-rss

Conversation

@samvallad33

@samvallad33 samvallad33 commented Aug 27, 2026

Copy link
Copy Markdown

Oneshot retirement already drives activeUserWorkersCount to 0. Host RSS still grows ~2.5 MiB per isolate.

The worker is gone from the pool; the isolate's host pages are not. V8 leaves committed heap on the pinned worker thread, and that thread's allocator never returns those pages (mi_collect / malloc_trim / malloc_zone_pressure_relief). EdgeRuntime.miCollect() only purges the main worker.

This decommits the isolate on termination and drops host allocator pages in DenoRuntime::drop after JsRuntime dispose, on the same thread that owned the isolate.

test_oneshot_retirement_drops_user_worker checks the pool count hits 0 after oneshot shutdown. It does not measure RSS.

Fixes #719

Retired workers already leave the pool (activeUserWorkersCount hits 0) while V8/host pages stay resident on the worker thread. Decommit the isolate and purge that thread's allocator after JsRuntime drop.
@kallebysantos
kallebysantos self-requested a review August 29, 2026 02:22
@kallebysantos kallebysantos self-assigned this Aug 29, 2026
@samvallad33
samvallad33 marked this pull request as ready for review August 30, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retired user workers are not fully reclaimed — RSS grows ~2.5 MiB per retirement with activeUserWorkersCount: 0 (v1.74.3, policy = oneshot)

2 participants