alibaba / alibaba/flutter_boost

[Bug]: 使用fragmentactivity加载FlutterBoostFragment页面关闭时会内存泄露

Open
#1,916 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

### 请描述遇到的问题,以及您所期望的正确的结果

使用fragmentactivity加载FlutterBoostFragment页面关闭时会内存泄露

### 请说明如何操作会遇到上述问题

新建页面,然后关闭页面

┬───
│ GC Root: Thread object

├─ Fl instance
│ Leaking: NO (PathClassLoader↓ is not leaking)
│ Thread name: 'CleanupReference'
│ ↓ Thread.contextClassLoader
├─ 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[5342]
├─ 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 1.0 kB in 33 objects
│ ↓ FlutterEngine.dartExecutor
│ ~~~~~~~~~~~~
├─ io.flutter.embedding.engine.dart.DartExecutor instance
│ Leaking: UNKNOWN
│ Retaining 90 B in 3 objects
│ ↓ DartExecutor.dartMessenger
│ ~~~~~~~~~~~~~
├─ io.flutter.embedding.engine.dart.DartMessenger instance
│ Leaking: UNKNOWN
│ Retaining 109.3 kB in 2290 objects
│ ↓ DartMessenger.messageHandlers
│ ~~~~~~~~~~~~~~~
├─ java.util.HashMap instance
│ Leaking: UNKNOWN
│ Retaining 108.1 kB in 2234 objects
│ ↓ HashMap["flutter/keyboard"]
│ ~~~~~~~~~~~~~~~~~~~~
├─ io.flutter.embedding.engine.dart.DartMessenger$HandlerInfo instance
│ Leaking: UNKNOWN
│ Retaining 104.9 kB in 2073 objects
│ ↓ DartMessenger$HandlerInfo.handler
│ ~~~~~~~
├─ io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler instance
│ Leaking: UNKNOWN
│ Retaining 104.9 kB in 2072 objects
│ ↓ MethodChannel$IncomingMethodCallHandler.handler
│ ~~~~~~~
├─ io.flutter.embedding.engine.systemchannels.KeyboardChannel$1 instance
│ Leaking: UNKNOWN
│ Retaining 104.9 kB in 2070 objects
│ Anonymous class implementing io.flutter.plugin.common.MethodChannel$MethodCallHandler
│ ↓ KeyboardChannel$1.this$0
│ ~~~~~~
├─ io.flutter.embedding.engine.systemchannels.KeyboardChannel instance
│ Leaking: UNKNOWN
│ Retaining 104.8 kB in 2068 objects
│ ↓ KeyboardChannel.keyboardMethodHandler
│ ~~~~~~~~~~~~~~~~~~~~~
├─ io.flutter.embedding.android.KeyboardManager instance
│ Leaking: UNKNOWN
│ Retaining 104.8 kB in 2067 objects
│ ↓ KeyboardManager.viewDelegate
│ ~~~~~~~~~~~~
├─ io.flutter.embedding.android.FlutterView instance
│ Leaking: YES (View.mContext references a destroyed activity)
│ Retaining 104.4 kB in 2051 objects
│ View is part of a window view hierarchy
│ View.mAttachInfo is null (view detached)
│ View.mID = R.id.null
│ View.mWindowAttachCount = 1
│ mContext instance of pro.ui.base.flutter.BaseFlutterFragmentActivity with mDestroyed = true
│ ↓ View.mContext

### 在下面填入关键复现代码

```
```

### 复现的平台

Android

### Flutter SDK版本

3.13.6

### FlutterBoost版本

4.4.0

### 是否延迟初始化FlutterBoost

No

### 解决方案

Contributor guide

No contributing guide indexed for this repository

Research direction

The report names FlutterBoostFragment, FragmentActivity, and FlutterEngineCache; start by reproducing the Android leak while inspecting the retention path shown in the trace. Done means the destroyed activity is no longer retained after closing the page, verified with the same leak check.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart
Domain
mobile, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.