flutter-memory-leak-engineering
Installation
SKILL.md
Flutter Memory Leak Engineering
Operating rules
- Diagnose ownership before adding cleanup calls.
- Treat
leak_trackeras lifecycle verification, not as a universal heap leak detector. - Distinguish
notDisposed,notGCed, andgcedLate; they describe different failures and require different fixes. - Separate disposal from garbage collection: disposed objects can remain retained, and collected objects can still have violated a cleanup contract.
- Prefer one clear owner for every disposable/cancelable/removable resource.
- Keep longer-lived objects from retaining shorter-lived widgets, routes, sessions, controllers, or
BuildContextunless the lifetime is intentional. - Use standard not-disposed checking as the high-signal default; enable expensive/experimental retention diagnostics only for focused investigations.
- Do not silence failures before finding the creation site, owner, teardown path, and retaining reference.
- Do not treat increasing RSS as proof of a tracked Dart lifecycle leak.
- Escalate unresolved growth or retaining chains to Flutter DevTools Memory.
- Keep fixed lifecycle bugs as deterministic regression tests.
- Preserve repository architecture unless ownership/lifetime is actually wrong.
Research baseline and freshness
The supplied guide targets leak_tracker 11.0.2 and the current split between:
leak_trackerfor core tracking/classification;leak_tracker_testingfor test helpers;leak_tracker_flutter_testingfor Flutter widget-test integration;- Flutter
FlutterMemoryAllocationsfor framework lifecycle instrumentation;