-
-
Notifications
You must be signed in to change notification settings - Fork 504
Description
Describe the bug
The application is leaking memory when opening and closing the application.
Minimal reproduction project
Example project produces this report.
To Reproduce
Steps to reproduce the behavior:
- Run the example project.
- Open the app.
- Close the app using back button.
- Leak canary will generate a report.
Expected behavior
No memory leaks should be present in the application.
Leak Canary Report
ApplicationLeak(className=com.ryanheise.audioserviceexample.MainActivity, leakTrace=
┬
├─ android.os.HandlerThread
│ Leaking: NO (PathClassLoader↓ is not leaking)
│ Thread name: 'LeakCanary-Heap-Dump'
│ GC Root: Thread object
│ ↓ thread HandlerThread.contextClassLoader
├─ dalvik.system.PathClassLoader
│ Leaking: NO (Object[]↓ is not leaking and A ClassLoader is never leaking)
│ ↓ PathClassLoader.runtimeInternalObjects
├─ java.lang.Object[]
│ Leaking: NO (AudioServicePlugin↓ is not leaking)
│ ↓ array Object[].[512]
├─ com.ryanheise.audioservice.AudioServicePlugin
│ Leaking: NO (a class is never leaking)
│ ↓ static AudioServicePlugin.clientHandler
│ ~~~~~~~~~~~~~
├─ com.ryanheise.audioservice.AudioServicePlugin$ClientHandler
│ Leaking: UNKNOWN
│ ↓ AudioServicePlugin$ClientHandler.connectionCallback
│ ~~~~~~~~~~~~~~~~~~
├─ com.ryanheise.audioservice.AudioServicePlugin$ClientHandler$3
│ Leaking: UNKNOWN
│ Anonymous subclass of android.support.v4.media.MediaBrowserCompat$ConnectionCallback
│ ↓ AudioServicePlugin$ClientHandler$3.mConnectionCallbackInternal
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
├─ android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi26
│ Leaking: UNKNOWN
│ ↓ MediaBrowserCompat$MediaBrowserImplApi26.mContext
│ ~~~~~~~~
╰→ com.ryanheise.audioserviceexample.MainActivity
Leaking: YES (Activity#mDestroyed is true and ObjectWatcher was watching this)
key = 67498789-00a3-42fe-b139-6eaddb476355
watchDurationMillis = 5135
retainedDurationMillis = 133
, retainedHeapByteSize=22818)
Runtime Environment:
- Device: [10.or G]
- Android version: [8.1.0]
Flutter SDK version
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 10.0.18363.476], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.40.2)
[√] Connected device (1 available)
• No issues found!
Additional Context
Leak Canary getting started
dependencies {
// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
}