vmConnected property
Clear all session state on VM disconnect.
Without this cleanup, in-flight timers or reconnection delays let pre-disconnect samples leak into a post-reconnect window:
- GC sliding window inflates rate, triggering
gc_pressureon a freshly reconnected app that has not actually GC'd yet. - Heap samples preserve a slope from the prior session, causing
heap_growingto fire on the first post-reconnect sample. - The sample leg's sustain start survives, so a heap_growing issue emitted
post-reconnect carries a
dedupIdentityMicrosderived from a prior-session timestamp — corrupting the producer-side dedup composite key and the runtimeVerified audit trail.
Clearing every identity-bearing field on disconnect guarantees the next reconnect starts fresh: warmup re-runs, dedup identities are freshly derived, and the budget window does not pre-charge with stale over-budget samples.
_evaluate() runs after the clear so any stale issue still in
_issues is removed from the UI immediately, rather than lingering
until the next GC event or heap sample arrives (which may be never
on a failed-reconnect path).
Implementation
@override
set vmConnected(bool value) {
// A new session starts without a pause baseline. A manual reconnect
// while connected never reports `false`, and the GC events missed
// during its backoff (up to 16 s) would otherwise all be booked into
// the first event of the new session.
_lastCumulativePauseSeconds = null;
// Collections from before the change belong to another session.
_floor.clear(notBeforeMs: _floorNotBeforeNow());
if (!value) {
_gcWindow.clear();
_heapSamples.clear();
_budgetCrossingStart = null;
_sampleSustainedStart = null;
_sustainedNativeGrowthStart = null;
_firstHeapSampleTime = null;
_lastHeapGrowingEmittedAtMicros = null;
_endEpisode();
_evaluate();
}
super.vmConnected = value;
}