workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

Support eager memory deallocation on hibernation

Open guybedford opened this issue 3 months ago • 3 comments

While formally not a memory leak, this reduces Wasm memory usage for durable objects subject to hibernation by eagerly freeing Wasm memory associated with the stale instance when a new instance is constructed.

guybedford avatar Sep 26 '25 01:09 guybedford

Unfortunately this fails because destroying the last instance when a new instance is constructed doesn't work since it seems we support constructing multiple in the same isolate of a given durable object.

guybedford avatar Sep 26 '25 01:09 guybedford

It turns out this requires upstream work to properly support, given the multi-DO handling.

guybedford avatar Sep 26 '25 01:09 guybedford

An upstream change for an unload event is posted in https://github.com/cloudflare/workerd/pull/5211.

guybedford avatar Oct 02 '25 00:10 guybedford