runScoped<R> static method
Runs body inside an isolated tracking scope.
Allocations performed within this scope:
- are tracked independently from outer scopes
- use their own registry
- may optionally use a custom
filter
This is particularly useful for tests, benchmarks, or short-lived diagnostic sessions where isolation is required.
Implementation
static R runScoped<R>(R Function() body, {LeakFilter? filter}) {
final registry = <int, Allocation>{};
return runZoned(
body,
zoneValues: {#_enabled: true, #_filter: filter, #_registry: registry},
);
}