Realme RMX3501内存泄漏

问题描述 投票:0回答:1

在 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

如何重现错误:

  1. 点击按钮
  2. 单击“后退”按钮 结果:
  1. 点击按钮
  2. 点击按钮
android kotlin memory-leaks garbage-collection
1个回答
0
投票

内存泄漏与OPPO厂商对Android 13 ROM的修改有关

他们在WindowManagerImpl中创建了一个内部非静态类ThreeFlingerObserver的实例,并将其注册到ContentResolver,但从未注销它,这将导致内存泄漏。

© www.soinside.com 2019 - 2024. All rights reserved.