alibaba / alibaba/flutter_boost
内存泄漏
- Dominant language
- Dart
- Stars
- 7.2k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
## 复现步骤:
1、build.gradle中添加‘leakcanary-android:2.9.1’检测库
2、FB自带demo中点击 “open custom view page”。
3、返回键退出。
4、报告有内存泄漏。
## log:
┬───
│ GC Root: Input or output parameters in native code
│
├─ dalvik.system.PathClassLoader instance
│ Leaking: NO (FlutterEngineCache↓ is not leaking and A ClassLoader is never leaking)
│ ↓ ClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│ Leaking: NO (FlutterEngineCache↓ is not leaking)
│ ↓ Object[645]
├─ io.flutter.embedding.engine.FlutterEngineCache class
│ Leaking: NO (a class is never leaking)
│ ↓ static FlutterEngineCache.instance
│ ~~~~~~~~
├─ io.flutter.embedding.engine.FlutterEngineCache instance
│ Leaking: UNKNOWN
│ Retaining 140 B in 4 objects
│ ↓ FlutterEngineCache.cachedEngines
│ ~~~~~~~~~~~~~
├─ java.util.HashMap instance
│ Leaking: UNKNOWN
│ Retaining 128 B in 3 objects
│ ↓ HashMap["flutter_boost_default_engine"]
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
├─ io.flutter.embedding.engine.FlutterEngine instance
│ Leaking: UNKNOWN
│ Retaining 5.2 kB in 142 objects
│ ↓ FlutterEngine.platformViewsController
│ ~~~~~~~~~~~~~~~~~~~~~~~
├─ io.flutter.plugin.platform.PlatformViewsController instance
│ Leaking: UNKNOWN
│ Retaining 680 B in 21 objects
│ context instance of com.idlefish.flutterboost.example.tab.TabCustomViewActivity with mDestroyed = true
│ ↓ PlatformViewsController.context
│ ~~~~~~~
╰→ com.idlefish.flutterboost.example.tab.TabCustomViewActivity instance
Leaking: YES (ObjectWatcher was watching this because com.idlefish.flutterboost.example.tab.TabCustomViewActivity
received Activity#onDestroy() callback and Activity#mDestroyed is true)
Retaining 45.0 kB in 773 objects
key = 67860805-c7c7-41f4-a33d-c548975d52ec
watchDurationMillis = 6707
retainedDurationMillis = 1665
mApplication instance of com.idlefish.flutterboost.example.MyApplication
mBase instance of android.app.ContextImpl
## 环境
**Flutter Boost Version**:4.2.0
**Target Platform**: Android
**Target OS version/browser:** android 10
**Devices:** Android模拟器
## `flutter doctor -v`:
```
[✓] Flutter (Channel stable, 3.0.5, on macOS 13.1 22C65 darwin-arm, locale zh-Hans-CN)
• Flutter version 3.0.5 at /Users/zfn/workspace/flutter/sdk/google/flutter-3.0.5
• Upstream repository https://github.com/flutter/flutter.git
• FLUTTER_GIT_URL = https://gitee.com/mirrors/Flutter.git
• Framework revision f1875d570e (7 months ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/zfn/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• ANDROID_HOME = /Users/zfn/Library/Android/sdk
• Java binary at: /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
• All Android licenses accepted.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the leak from the FB demo by opening the custom view page and pressing Back, with LeakCanary 2.9.1 configured in build.gradle. Start by tracing the reported FlutterEngineCache → PlatformViewsController.context path and compare it with the destroyed TabCustomViewActivity. Done means the activity is no longer retained after onDestroy and the leak report is cleared.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100