Skip to content

OverlayEntry is not disposed #386

Description

@finnvyrn

Version

3.2.0

Library

feedback

Flutter channel

stable

Flutter version

3.41.6

Platform

Android

Details

┌─────────────────────────────────────────────────
I/flutter (18203): │ #0   leakTrackerInit.<anonymous closure> (package:my_app/core/presentation/function/main_init/leak_tracker_init.dart:27:18)
leak_tracker_init.dart:27
I/flutter (18203): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (18203): │ +0:00:28.164584
I/flutter (18203): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (18203): │ notDisposed:OverlayEntry:
I/flutter (18203): │ notDisposed:  identityHashCode: 431158469
I/flutter (18203): │ notDisposed:  context:
I/flutter (18203): │ notDisposed:    start: >
I/flutter (18203): │   notDisposed:    #6______leakTrackerInit.<anonymous_closure>_(package:my_app/core/presentation/function/main_init/leak_tracker_init.dart:43:41)
leak_tracker_init.dart:43
I/flutter (18203): │   notDisposed:    #7______FlutterMemoryAllocations.dispatchObjectEvent_(package:flutter/src/foundation/memory_allocations.dart:243:23)
memory_allocations.dart:243
I/flutter (18203): │   notDisposed:    #8______FlutterMemoryAllocations.dispatchObjectCreated_(package:flutter/src/foundation/memory_allocations.dart:281:5)
memory_allocations.dart:281
I/flutter (18203): │   notDisposed:    #9______debugMaybeDispatchCreated_(package:flutter/src/foundation/debug.dart:152:39)
debug.dart:152
I/flutter (18203): │   notDisposed:    #10_____new_OverlayEntry_(package:flutter/src/widgets/overlay.dart:121:12)
overlay.dart:121
I/flutter (18203): │   notDisposed:    #11_____FeedbackWidgetState.build_(package:feedback/src/feedback_widget.dart:146:9)
feedback_widget.dart:146
I/flutter (18203): │   notDisposed:    #12_____StatefulElement.build_(package:flutter/src/widgets/framework.dart:5931:27)
framework.dart:5931
I/flutter (18203): │   notDisposed:    #13_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5817:15)
framework.dart:5817
I/flutter (18203): │   notDisposed:    

Steps to reproduce

  • Use feedback widget to wrap a MaterialApp
  • Open a dialog from anywhere.
  • Add leak_tracker to pubspec.yaml
  • flutter pub get
  • Initialize leak tracker in main() before runApp() by calling the following function:
void leakTrackerInit() {
  LeakTracking.phase = const PhaseSettings(
    ignoredLeaks: IgnoredLeaks(
      // experimentalNotGCed: IgnoredLeaksSet(ignoreAll: false),
    ),
    leakDiagnosticConfig: LeakDiagnosticConfig(
      collectRetainingPathForNotGCed: true,
      collectStackTraceOnStart: true,
      collectStackTraceOnDisposal: true,
    ),
  );
  LeakTracking.start(
    config: LeakTrackingConfig(
      onLeaks: (s) async {
        logger.i('onLeak: ${s.toJson()}');

        final Leaks leaks = await LeakTracking.collectLeaks();

        //a disposable object was GCed, without being disposed first.
        //This means that the object's disposable content is using memory after the object is no longer needed.
        for (final LeakReport n in leaks.notDisposed) {
          logger.e(n.toYaml('notDisposed:', phasesAreTests: true));
        }
        //an object was disposed, but not GCed after certain number of GC events.
        //This means that a reference to the object is preventing it from being garbage collected after it's no longer needed.
        for (final LeakReport n in leaks.notGCed) {
          logger.f(n.toYaml('notGCed:', phasesAreTests: true));
        }
        //an object was disposed and then GCed, but GC happened later than expected.
        //This means the retaining path was holding the object in memory for some period, but then disappeared.
        for (final LeakReport n in leaks.gcedLate) {
          logger.w(n.toYaml('gcedLate:', phasesAreTests: true));
        }
      },
    ),
  );
  FlutterMemoryAllocations.instance.addListener(
    (ObjectEvent event) => LeakTracking.dispatchObjectEvent(event.toMap()),
  );

  // Used after test execution
  // LeakTracking.declareNotDisposedObjectsAsLeaks();
}

Output of flutter doctor -v

~/projects/my_app> fldc
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[✓] Flutter (Channel stable, 3.41.6, on Arch Linux 6.19.11-1-cachyos, locale en_US.UTF-8) [30ms]
    • Flutter version 3.41.6 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db50e20168 (9 days ago), 2026-03-25 16:21:00 -0700
    • Engine revision 425cfb54d0
    • Dart version 3.11.4
    • DevTools version 2.54.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • Feature flags: no-enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [11.1s]
    • Android SDK at /home/finn/Android/Sdk
    • Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
    • ANDROID_HOME = /home/finn/Android/Sdk
    • Java binary at: /opt/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.9+-14787801-b1163.94)
    • All Android licenses accepted.

[✓] Linux toolchain - develop for Linux desktop [197ms]
    • clang version 22.1.2
    • cmake version 4.3.1
    • ninja version 1.13.2
    • pkg-config version 2.5.1
    • OpenGL core renderer: AMD Radeon RX 7600 (radeonsi, navi33, ACO, DRM 3.64, 6.19.11-1-cachyos)
    • OpenGL core version: 4.6 (Core Profile) Mesa 26.0.3-arch2.2
    • OpenGL core shading language version: 4.60
    • OpenGL ES renderer: AMD Radeon RX 7600 (radeonsi, navi33, ACO, DRM 3.64, 6.19.11-1-cachyos)
    • OpenGL ES version: OpenGL ES 3.2 Mesa 26.0.3-arch2.2
    • OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
    • GL_EXT_framebuffer_blit: yes
    • GL_EXT_texture_format_BGRA8888: yes

[✓] Connected device (2 available) [75ms]
    • SM F9460 (mobile) • RFCW71F6FXL • android-arm64 • Android 16 (API 36)
    • Linux (desktop)   • linux       • linux-x64     • Arch Linux 6.19.11-1-cachyos

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions