Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leaks on iOS #23231

Closed
dddrop opened this issue Oct 18, 2018 · 9 comments
Closed

Memory Leaks on iOS #23231

dddrop opened this issue Oct 18, 2018 · 9 comments
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically

Comments

@dddrop
Copy link

dddrop commented Oct 18, 2018

Steps to Reproduce

Our team received some crash report about memory leaks from a ListView. By testing, we found a weird things that just happens on a release build(or Profiling).

We simplify our code like:

import 'package:flutter/material.dart';
import 'dart:math';


var imageURLs =[
  // 
  // URLs
  //
];

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => new _MainPageState();
}

class _MainPageState extends State<MainPage> {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "Image Leaker",
      theme: new ThemeData.dark(),
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text("Image Leaker"),
        ),
        body: _buildList(),
      ),
    );
  }

  Widget _buildList() {
    return ListView.builder(
        itemBuilder: (context, i) {

          return _buildItem(Random().nextInt(imageURLs.length));
    });
  }

  Widget _buildItem(int k){
    return Container(
      height: 100.0,
      child: new Image.network(imageURLs[k]),
    );
  }
}

void main() => runApp(new MainPage());
  1. put some image links in imageURLs.
  2. run Profile on a iOS device.

and detect memory leaks by scrolling the ListView.

btw, it problem not happens on a text list.

Logs

screen shot 2018-10-18 at 10 25 06

flutter docker -v:

[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.13.6 17G2307, locale en-JP)
    • Flutter version 0.8.2 at /Users/dddrop/flutter
    • Framework revision 5ab9e70727 (6 weeks ago), 2018-09-07 12:33:05 -0700
    • Engine revision 58a1894a1c
    • Dart version 2.1.0-dev.3.1.flutter-760a9690c2

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/dddrop/Library/Android/sdk
    • Android NDK at /Users/dddrop/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.1.1
    • Dart plugin version 181.5540.11
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.4)
    • IntelliJ at /Users/dddrop/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 29.1.3
    • Dart plugin version 182.4999

[✓] Connected devices (1 available)
@zoechi
Copy link
Contributor

zoechi commented Oct 18, 2018

Flutter 0.8.2 is a bit outdated. I think there also were some related changes recently.
Can you check if you can reproduce in Flutter master channel (10.x.x)?

@zoechi zoechi added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 18, 2018
@dddrop
Copy link
Author

dddrop commented Oct 18, 2018

I rebuild with master, and there are still several leaks.

screen shot 2018-10-18 at 16 44 40

[✓] Flutter (Channel master, v0.10.1-pre.76, on Mac OS X 10.13.6 17G2307, locale en-JP)
    • Flutter version 0.10.1-pre.76 at /Users/dddrop/flutter
    • Framework revision b0787b900f (3 hours ago), 2018-10-17 21:49:37 -0700
    • Engine revision 8cc49cac3b
    • Dart version 2.1.0-dev.7.1.flutter-b99bcfd309

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/dddrop/Library/Android/sdk
    • Android NDK at /Users/dddrop/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.1.1
    • Dart plugin version 181.5540.11
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.4)
    • IntelliJ at /Users/dddrop/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 29.1.3
    • Dart plugin version 182.4999

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 18, 2018
@zoechi
Copy link
Contributor

zoechi commented Oct 18, 2018

@dddrop thanks for checking!

@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. c: performance Relates to speed or footprint issues (see "perf:" labels) labels Oct 18, 2018
@zoechi zoechi added this to the Goals milestone Oct 18, 2018
@najeira
Copy link
Contributor

najeira commented Oct 18, 2018

with master, the leak seems to be decreasing.

I want to cherry-pick the fix, if you know, could you tell me the related commit?

@dddrop
Copy link
Author

dddrop commented Oct 19, 2018

@zoechi

we did another test on only Text that fetch data from apis, and also found leaks. So maybe these leaks are caused by network task?

@goderbauer goderbauer added platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. f: scrolling Viewports, list views, slivers, etc. labels Jan 3, 2019
@Natoto
Copy link

Natoto commented Mar 5, 2019

@Natoto
Copy link

Natoto commented Mar 5, 2019

@dnfield
Copy link
Contributor

dnfield commented May 18, 2020

I believe this has been fixed. I'm going to close this - please feel free to re-open with a full reproduction if you're still seeing leaks.

@dnfield dnfield closed this as completed May 18, 2020
Mobile - iOS performance review automation moved this from Awaiting triage to Engineer reviewed May 18, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically
Projects
Mobile - iOS performance review
  
Engineer reviewed
Development

No branches or pull requests

6 participants