There are no memory leaks on android 11 Realme RMX3501 (C31), and there are no memory leaks on other devices that I have.On 13 android with RMX3501_13.F.54 firmware, activity is constantly leaking.
The activity leaks every time onDestroy is called
Below is an example.
What can it be related to?
│ 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
There are no memory leaks on android 11 Realme RMX3501 (C31), and there are no memory leaks on other devices that I have.
UPD: I Created a simple test project https://github.com/Vanilla1999/Test
How to reproduce the error:
The above memory leak is releated to the modification in Android 13 ROM by the manafuctor OPPO.
They created a instance of non-static inner class ThreeFlingerObserver in WindowManagerImpl and register it to the ContentResolver but never unregister it, which will lead to the memory leak and oom at last.