在 android 11 Realme RMX3501 (C31) 上没有内存泄漏,在我拥有的其他设备上也没有内存泄漏。在具有 RMX3501_13.F.54 固件的 13 android 上,活动不断泄漏。
每次调用 onDestroy 时,activity 都会泄漏 下面是一个例子。 可能和什么有关系?
│ GC Root: Global variable in native code
│
├─ android.database.ContentObserver$Transport instance
│ Leaking: UNKNOWN
│ Retaining 822 B in 9 objects
│ ↓ ContentObserver$Transport.mContentObserver
│ ~~~~~~~~~~~~~~~~
├─ android.view.WindowManagerImpl$ThreeFingerObserver instance
│ Leaking: UNKNOWN
│ Retaining 286 B in 8 objects
│ ↓ WindowManagerImpl$ThreeFingerObserver.this$0
│ ~~~~~~
├─ android.view.WindowManagerImpl instance
│ Leaking: UNKNOWN
│ Retaining 78 B in 3 objects
│ mContext instance of android.app.ContextImpl
│ ↓ WindowManagerImpl.mContext
│ ~~~~~~~~
├─ android.app.ContextImpl instance
│ Leaking: YES (ContextImpl.mOuterContext is an instance of ru.price.mobilescoutnative.camera.completephoto.
│ CompletePhotoActivity with Activity.mDestroyed true)
│ Retaining 6,9 kB in 104 objects
│ mOuterContext instance of ru.price.mobilescoutnative.camera.completephoto.CompletePhotoActivity with mDestroyed =
│ true
│ ↓ ContextImpl.mOuterContext
╰→ ru.price.mobilescoutnative.camera.completephoto.CompletePhotoActivity instance
Leaking: YES (ObjectWatcher was watching this because ru.price.mobilescoutnative.camera.completephoto.
CompletePhotoActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
Retaining 16,0 MB in 836 objects
key = 0b60122b-03ad-4fc0-bfc3-6b60e1b5b406
watchDurationMillis = 59595
retainedDurationMillis = 54595
mApplication instance of ru.price.mobilescoutnative.App
mBase instance of androidx.appcompat.view.ContextThemeWrapper
在android 11 Realme RMX3501(C31)上没有内存泄漏,在我拥有的其他设备上也没有内存泄漏。
更新: 我创建了一个简单的测试项目https://github.com/Vanilla1999/Test
如何重现错误: