Repository navigation
Clean up 'not disposed' memory leaks in FF, phase 3. #141198
Description
Looking for volunteers to help with this!!! 🚀
Bigger issue: #134787
Goal
Clean up remaining memory leaks (~25) in order to switch to leak monitoring state.
Steps
In general:
- Leak tracking is disabled by default, but enabled just for three non-blocking windows bots. To enable leak tracking for tests locally, search for
if (isLeakTrackingEnabled()) {in the code and temporary replace it withif (true). - If you create an issue or PR for cleanups, cc @polina-c
- Update everybody on your plans by commenting on this issue, so that we do not duplicate effort.
- If your PR stops ignoring leaks for some tests, trigger leak verifying bots for your PR: find them in code by
_leak_trackingand temporarily comment outbringup: true. - Ping me on GitHub or twitter (PolinaCC) if a PR is waiting for something more than one business day
- If your PR or issue is closed, and you noticed I forgot to add label
a: leak tracking, remind me, please
Fix a memory leak:
-
Identify a leak from one of the sources:
a. flutter dashboard
Look for 3 windows icons on the top left with tooltip ending "leak_tracking".
If one of them have the last execution failing, open itstest stdoutand search forcontains leaks:.b. Known not-investigated leaky test
Search for[leaks-to-clean]in flutter/testc. Not assigned known issue
Assign the issue to yourself. -
Investigate the leak.
ifthere is a known issue for the leak and it is assigned
then:add/update TODO for the leak (see template below)
else:(fix the leak) or (create new issue and add the leak TODO to the test)
Or instrument a disposable (example):
- AnimationEagerListenerMixin - no need to instrument
- CurvedAnimation
- TrainHoppingAnimation: TrainHoppingAnimation should dispatch creation and disposal events. #141635
- ImageInfo: Instrument ImageInfo. #141411
- BoxPainter: BoxPainter should dispatch creation and disposal events. #141526
- ScrollDragController
- SelectionOverlay
- SnapshotPainter
- TextSelectionOverlay
Templates
Leak tracking opt-out TODO:
testWidgets('<test name>',
// TODO(< polina-c | your alias >): <explanation and link to issue> [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { ...
Leak tracking opt-in TODO (when tracking is opted out in flutter_test_config.dart or in the entire test file):
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: <String>['CurvedAnimation']),
(WidgetTester tester) async { ...
Steps to repro (to be copied to issues):
To repro the leak:
- Copy link to the issue
- Search for the copied link in Flutter source code. You will find number of TODOs marked [leaks-to-clean].
- Remove the opting out line, one of the TODOs
- Run the test with the TODO, or, if it is global TODO, run all tests, with added --dart-define LEAK_TRACKING=true
- See the failure.
References
Issues: all, open, known leaks.
PRs: all, open.
Activity
polina-c commentedon Jan 11, 2024
CC those who participated in other leak tracking activities.
@BlackLeg15, @bivens-dev, @blaugold, @CoderBuck, @cmkweber, @davidmigloz, @Dean-Spotec, @droidbg, @felipecastrosales, @gustav3d, @Harishwarrior, @iapicca, @jayjah, @jogboms, @JohnnyRainbow81, @ksokolovskyi, @Levi-Lesches, @LucasXu0, @Markzipan, @mono0926, @Michal-MK, @navaronbracke, @NobodyForNothing, @noga-dev, @normidar, @p-mazhnik, @philos3, @PiN73, @rei-codes, @resfandiari, @sullenel, @tgucio,@victoreronmosele, @WillianSalceda
I am searching for volunteers to help on this issue.
polina-c commentedon Jan 12, 2024
Working to:
ksokolovskyi commentedon Jan 12, 2024
@polina-c
ScrollDragController,SelectionOverlay,TextSelectionOverlay, andSnapshotPainterare already instrumented, could you please add checkmarks for them?polina-c commentedon Jan 12, 2024
@ksokolovskyi
Done. Thank you.
Reverts "BoxPainter should dispatch creation and disposal events." (#…
polina-c commentedon Jan 25, 2024
Progress check: ~50 laking tests or test files.
polina-c commentedon Jan 30, 2024
Tagged remaining leaks with [leaks-to-clean].
There are 38.
Add CurvedAnimation disposals in some widgets (#143790)
polina-c commentedon Feb 28, 2024
CurvedAnimation is leaking a lot. I need to recount leaks after this instrumentation :)
polina-c commentedon Mar 10, 2024
To repro a leak:
--dart-define LEAK_TRACKING=truepolina-c commentedon May 1, 2024
See remaining leaks of CurvedAnimation here.
Reverts "Fix memory leak in `TabPageSelector` (#147403)" (#147622)
fixes `RawDialogRoute` memory leak (#147817)
`_RenderValueIndicator` leak fix used on `RangeSlider` (#147581)
ismailcaakir commentedon Jun 2, 2024
polina-c commentedon Jun 3, 2024
github-actions commentedon Mar 4, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.