Skip to content

Memory leak on flutter web when using Icon in ListView #122189

@IvoB1987

Description

@IvoB1987

Details

Consider this simple full application:

import 'package:flutter/material.dart';
void main() {
  runApp(const MaterialApp(
    home: Scaffold(body: MemoryTest()),
  ));
}

class MemoryTest extends StatelessWidget {
  const MemoryTest({super.key});
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: 500,
      itemBuilder: (context, index) => const Icon(Icons.circle)
    );
  }
}

When running on web the memory keeps increasing indefinitely while scrolling through the list, as can seen in the Task Manager of Windows. Is this a bug in Flutter or how can I rewrite this code to prevent the memory leak? Simply replacing the Icon with a Text does not cause a leak.

Target Platform: web
Target OS version/browser: Chrome Version 110.0.5481.180 (Official Build) (64-bit)
Devices: Windows 10

Logs

Logs
Analyzing fluttertest...                                                
No issues found! (ran in 0.8s)
[√] Flutter (Channel stable, 3.7.6, on Microsoft Windows [Version 10.0.19045.2604], locale en-DK)
    • Flutter version 3.7.6 on channel stable at C:\Users\ivb\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12cb4eb7a0 (7 days ago), 2023-03-01 10:29:26 -0800
    • Engine revision ada363ee93
    • Dart version 2.19.3
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\ivb\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.5.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Enterprise
    • Visual Studio Enterprise 2022 version 17.5.33414.496
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 11.0.15+0-b2043.56-9505619)

[√] IntelliJ IDEA Community Edition (version 2022.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1
    • Flutter plugin version 72.1.4
    • Dart plugin version 223.8617.8

[√] VS Code (version 1.72.2)
    • VS Code at C:\Users\ivb\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2604]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 110.0.5481.180
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 110.0.1587.63

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressionc: performanceRelates to speed or footprint issues (see "perf:" labels)c: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions