Skip to content

Memory leaks occur when an activity is destroyed and recreated. Android os #173770

Closed

Description

@SJLBenjamin

Note

For anyone looking at this issue now, this leak was introduced by 233edc0 in Flutter 3.29.

1.Create a Flutter project using Android Studio.

2.Enter the developer options, set not to keep activities, (destroy each activity as soon as the user leaves it)

3.Entering the activity, clicking the home button, exiting the activity, and then entering the activity again will trigger the destruction and reconstruction of the activity.

4.Check memory leaks through profiler and find memory leaks

Image

5.In actual use, the same problem will occur if the system kills the activity due to insufficient memory.

6.The same problem occurred with 3.27.1 and 3.32.8

Activity

  1. tirth-patel-nc commented on Aug 14, 2025

    @tirth-patel-nc
    Member

    @SJLBenjamin Report seems vague. For us to further investigate this issue, please provide a completed and minimal reproducible code sample that doesn’t include 3rd party plugins or complex production code. Also, please share the output flutter doctor -v. Thank you!

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 14, 2025
  3. SJLBenjamin commented on Aug 15, 2025

    @SJLBenjamin
    Author

    @SJLBenjamin Report seems vague. For us to further investigate this issue, please provide a completed and minimal reproducible code sample that doesn’t include 3rd party plugins or complex production code. Also, please share the output flutter doctor -v. Thank you!

    example:
    memorydemosjl.zip

    flutter doctor -v:

    Image

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 15, 2025
  5. tirth-patel-nc commented on Aug 15, 2025

    @tirth-patel-nc
    Member

    @SJLBenjamin please confirm whether #145750, #168658 are related to your case

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 15, 2025
  7. SJLBenjamin commented on Aug 15, 2025

    @SJLBenjamin
    Author

    @SJLBenjamin please confirm whether #145750, #168658 are related to your case

    It should not be related to me, because after creating the project with Android studio, the code has not been changed, and I have the necessary path

  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 15, 2025
  9. tirth-patel-nc commented on Aug 18, 2025

    @tirth-patel-nc
    Member

    Thanks for the update. I'm observing the same behaviour on the latest SDK versions.

    I enabled Don't keep activities in Developer options and tested it on both an emulator and a physical android device.

    stable : 3.32.8, 3.35.1
    master : 3.33.0-1.0.pre-1457
    beta : 3.36.0-0.1.pre
    
    Image Image

    so it looks similar to #23181, but that one is too old to be a valid reference in this case.

  10. added
    platform-androidAndroid applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 18, 2025
  11. 14 remaining items

  12. liweiGe commented on Sep 16, 2025

    @liweiGe
    Image I used this code to temporarily solve it, but I still have to wait for the SDK to be updated.
  13. github-actions commented on Oct 30, 2025

    @github-actions

    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 -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.found in release: 3.33Found to occur in 3.33found in release: 3.35Found to occur in 3.35frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions