Skip to content

Conversation

@yeatse
Copy link
Contributor

@yeatse yeatse commented May 24, 2022

When we call clear() to ImageCache, it will clear the _pendingImages list. According to

final _PendingImage? pendingImage = untrackedPendingImage ?? _pendingImages.remove(key);
if (pendingImage != null) {
pendingImage.removeListener();
}

cleared _PendingImage objects will never call removeListener(), so their memory will never be freed.

This PR tries to fix this issue.

closes #104522

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label May 24, 2022
@goderbauer goderbauer requested a review from dnfield May 24, 2022 21:18
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thanks for the detailed explanation and the test.

@dnfield
Copy link
Contributor

dnfield commented May 24, 2022

@goderbauer can you provide a secondary review?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluttergithubbot fluttergithubbot merged commit b5adbee into flutter:master May 24, 2022
@yeatse yeatse deleted the prevent-leaks-in-pending-image branch May 25, 2022 00:02
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request May 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 25, 2022
yzhtracy pushed a commit to BuildAndRelease/flutter that referenced this pull request Jun 15, 2022
yzhtracy pushed a commit to BuildAndRelease/flutter that referenced this pull request Jun 16, 2022
yzhtracy pushed a commit to BuildAndRelease/flutter that referenced this pull request Jun 17, 2022
yzhtracy pushed a commit to BuildAndRelease/flutter that referenced this pull request Jun 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If app is loading images and we put it to background, the memory is never released.

4 participants