[]previous and next page

What disposes what

What disposes what in the Effects and lifecycle guide.

For agentsUpdated

An owner is disposed when:

  • you call the function returned by render(), hydrate() or createRoot;
  • its parent is disposed (components, effects and memos are owners of what they create);
  • a memo or effect that created it re-runs (everything created during the previous run is disposed first);
  • control flow replaces it: a Show or Switch branch that is replaced, a For or Index row that leaves the list, an ErrorBoundary that switches to its fallback, a Dynamic whose component changes.

Disposal runs cleanups newest first, children before parents, and then the effects that depend on signals written by cleanups are flushed before the call returns (unless it happens inside a batch or a flush, whose own exit flushes).