From 85b66aea55f02d73209e880302edbae1b5432afe Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Fri, 5 Apr 2024 10:18:44 -0700 Subject: [PATCH] Update TROUBLESHOOT.md --- doc/leak_tracking/TROUBLESHOOT.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/leak_tracking/TROUBLESHOOT.md b/doc/leak_tracking/TROUBLESHOOT.md index 2fbba941..fd5b2757 100644 --- a/doc/leak_tracking/TROUBLESHOOT.md +++ b/doc/leak_tracking/TROUBLESHOOT.md @@ -198,3 +198,15 @@ If a found leak is originated in the Flutter Framework or a dependent package, f See the [tracking issue](https://github.com/flutter/flutter/issues/134787) for memory leak clean up in Flutter Framework. See documentation for [`testWidgets`](https://github.com/flutter/flutter/blob/4570d35d49477a53278e648ce59a26a06201ec97/packages/flutter_test/lib/src/widget_tester.dart#L122) to learn how to ignore leaks while a fix is on the way. + +### 4. Leaking object is Image + +Images in Flutter have unusual lifecycle. + +1. Image and ImageInfo have [non-standard contract for disposal](https://github.com/flutter/flutter/blob/1f64be86810ac4082e250fde8efc6ed212c538e1/packages/flutter/lib/src/painting/image_stream.dart#L18). + +2. The setting `.withIgnored(createdByTestHelpers: true)` does not work for images, because +creation of their native part is not detectable as happening in test helper. + +3. Images are cashed and reused that improves test performance. So, `tearDownAll(imageCache.clear)` +will help if leaks are caused by test code.