You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check memory profiler, you can see that each instance of AudioPlayer is retained despite dispose being called
Expected behavior
AudioPlayer and its dependencies should be completely freed following dispose()
Screenshots
Output of linked minimal reproduction project, which creates 100 AudioPlayer instances and sets an AudioSource before disposing the player:
Smartphone (please complete the following information):
Device: iPad 8th generation
OS: iOS 18.2
Device: iPhone 16 Pro Max Simulator
OS: iOS 18.2 (Simulator)
Flutter SDK version
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.1.1 24B91 darwin-x64, locale
en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.2)
Additional context
In my testing, the issue does not occur on Android.
Calling await player.stop() before dispose appears to resolve the problem
Adding the following code to dispose() appears to fix the issue:
Which API doesn't behave as documented, and how does it misbehave?
Some resources are retained despite calling player.dispose().
Minimal reproduction project
https://github.com/Colton127/just_audio/blob/fix_memleak/just_audio/example/lib/main.dart
To Reproduce
Steps to reproduce the behavior:
Expected behavior
AudioPlayer and its dependencies should be completely freed following dispose()
Screenshots
Output of linked minimal reproduction project, which creates 100 AudioPlayer instances and sets an AudioSource before disposing the player:
Smartphone (please complete the following information):
Device: iPad 8th generation
OS: iOS 18.2
Device: iPhone 16 Pro Max Simulator
OS: iOS 18.2 (Simulator)
Flutter SDK version
Additional context
Adding the following code to dispose() appears to fix the issue:
Though I'm unsure if this is a proper fix or just a workaround.
The text was updated successfully, but these errors were encountered: