Skip to content

Memory Leak: RenderAnimatedSize doesn't dispose AnimationController and CurvedAnimation #133903

Closed

Description

@ksokolovskyi

Is there an existing issue for this?

Steps to reproduce

RenderAnimatedSize creates AnimationController and CurvedAnimation but doesn't dispose them, which leads to a memory leak.

Creation of the AnimationController and CurvedAnimation:

RenderAnimatedSize({
required TickerProvider vsync,
required Duration duration,
Duration? reverseDuration,
Curve curve = Curves.linear,
super.alignment,
super.textDirection,
super.child,
Clip clipBehavior = Clip.hardEdge,
}) : _vsync = vsync,
_clipBehavior = clipBehavior {
_controller = AnimationController(
vsync: vsync,
duration: duration,
reverseDuration: reverseDuration,
)..addListener(() {
if (_controller.value != _lastValue) {
markNeedsLayout();
}
});
_animation = CurvedAnimation(
parent: _controller,
curve: curve,
);
}


dispose() method:

@override
void dispose() {
_clipRectLayer.layer = null;
super.dispose();
}
}


Expected results

The _controller and _animation are disposed in the dispose() method.

Actual results

The _controller and _animation aren't disposed in the dispose() method.

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.14.0-12.0.pre.107, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
    • Flutter version 3.14.0-12.0.pre.197 on channel master at /Users/ksokolovskyi/dev/flutter_master
    • Upstream repository [email protected]:ksokolovskyi/flutter.git
    • FLUTTER_GIT_URL = [email protected]:ksokolovskyi/flutter.git
    • Framework revision 42014a309b (23 seconds ago), 2023-09-02 12:02:02 +0200
    • Engine revision d00b69a438
    • Dart version 3.2.0 (build 3.2.0-128.0.dev)
    • DevTools version 2.27.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/ksokolovskyi/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = /Users/ksokolovskyi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Community Edition (version 2023.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 116.0.5845.140

[✓] Network resources
    • All expected network resources are available.

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Sep 4, 2023
  2. ksokolovskyi commented on Sep 11, 2023

    @ksokolovskyi
    ContributorAuthor
  3. github-actions commented on Sep 25, 2023

    @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.

  4. locked as resolved and limited conversation to collaborators on Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions