Skip to main content

prevent_gc

Function prevent_gc 

Source
pub fn prevent_gc()
Expand description

Pins the current task against garbage collection for the rest of the session, keeping it (and, via the reachability it anchors, the values it produced) alive even if it becomes disconnected from the live task graph. Use this when a value escapes the tracked graph — e.g. a Vc sent out of a spawn_detached future across a channel, or handed across the NAPI boundary — so no persistent parent lists it as a child and it would otherwise be collected.

No-op outside a task context, and on backends without garbage collection.