Coming soon! See https://github.com/flutter/devtools/issues/3951.
The text below is under construction.
This page describes how to troubleshoot memory leaks. See other information on memory leaks here.
If leak tracker detected a leak in your application or test, first check if the leak matches a known simple case, and, if no, switch to more complicated troubleshooting.
TODO: add steps.
To understand the root cause of a memory leak, you may want to gather additional information.
not-disposed:
not-GCed or GCed-late:
Allocation and disposal call-stacks: helps to understand lifecycle of the object which may reveal where the object is being held from garbage collection.
Other lifecycle events: TODO: add content
Retaining path: shows which objects hold the leaked one from garbage collection.
By default, the leak tracker does not collect stacktraces, because the collection may impact performance and memory footprint.
Temporarily setup stacktrace collection for your test:
testWidgets('My test', (WidgetTester tester) async { ... }, leakTrackingConfig: LeakTrackingTestConfig( stackTraceCollectionConfig: StackTraceCollectionConfig( classesToCollectStackTraceOnStart: {'MyClass'}, ) ));
There are options to enable stacktrace collection in applications:
stackTraceCollectionConfig
to enableLeakTracking
.TODO: link DevTools documentation with explanation
Open DevTools > Memory > Leaks, wait for not-GCed leaks to be caught, and click ‘Analyze and Download’.
TODO: add details