Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Call] Memory leak after a call #6808

Closed
mnaturel opened this issue Aug 11, 2022 · 0 comments · Fixed by #6809
Closed

[Call] Memory leak after a call #6808

mnaturel opened this issue Aug 11, 2022 · 0 comments · Fixed by #6809
Assignees
Labels
T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements

Comments

@mnaturel
Copy link
Contributor

Your use case

What would you like to do?

Unbind the callback from ScreenCaptureServiceConnection when the call activity is destroyed.

Why would you like to do it?

Leak canary reports the following leak:

┬───
│ GC Root: System class
│
├─ android.provider.FontsContract class
│    Leaking: NO (VectorApplication↓ is not leaking and a class is never
│    leaking)
│    ↓ static FontsContract.sContext
├─ [im.vector.app](http://im.vector.app/).VectorApplication instance
│    Leaking: NO (Application is a singleton)
│    appContext instance of [im.vector.app](http://im.vector.app/).VectorApplication
│    mBase instance of [android.app](http://android.app/).ContextImpl
│    ↓ Application.mLoadedApk
│                  ~~~~~~~~~~
├─ [android.app](http://android.app/).LoadedApk instance
│    Leaking: UNKNOWN
│    Retaining 330.8 kB in 6104 objects
│    mApplication instance of [im.vector.app](http://im.vector.app/).VectorApplication
│    Receivers
│    ..ContextImpl@362356288
│    ....VectorDebugReceiver@365507128
│    ..VectorApplication@336949856
│    ....VisibilityTracker@365499408
│    ....VectorApplication$powerKeyReceiver$1@365499480
│    ↓ LoadedApk.mServices
│                ~~~~~~~~~
├─ android.util.ArrayMap instance
│    Leaking: UNKNOWN
│    Retaining 328.7 kB in 6072 objects
│    ↓ ArrayMap.mArray
│               ~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    Retaining 328.6 kB in 6070 objects
│    ↓ Object[1]
│            ~~~
├─ android.util.ArrayMap instance
│    Leaking: UNKNOWN
│    Retaining 328.6 kB in 6069 objects
│    ↓ ArrayMap.mArray
│               ~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    Retaining 328.6 kB in 6067 objects
│    ↓ Object[0]
│            ~~~
├─ [im.vector.app.features.call](http://im.vector.app.features.call/).webrtc.ScreenCaptureServiceConnection instance
│    Leaking: UNKNOWN
│    Retaining 326.7 kB in 6056 objects
│    context instance of [im.vector.app](http://im.vector.app/).VectorApplication
│    ↓ ScreenCaptureServiceConnection.callback
│                                     ~~~~~~~~
├─ [im.vector.app.features.call](http://im.vector.app.features.call/).VectorCallActivity$bindToScreenCaptureService$1
│  instance
│    Leaking: UNKNOWN
│    Retaining 326.6 kB in 6055 objects
│    Anonymous class implementing [im.vector.app.features.call](http://im.vector.app.features.call/).webrtc.
│    ScreenCaptureServiceConnection$Callback
│    this$0 instance of [im.vector.app.features.call](http://im.vector.app.features.call/).VectorCallActivity with
│    mDestroyed = true
│    ↓ VectorCallActivity$bindToScreenCaptureService$1.this$0
│                                                      ~~~~~~
╰→ [im.vector.app.features.call](http://im.vector.app.features.call/).VectorCallActivity instance
​     Leaking: YES (ObjectWatcher was watching this because [im.vector.app](http://im.vector.app/).
​     [features.call](http://features.call/).VectorCallActivity received Activity#onDestroy() callback
​     and Activity#mDestroyed is true)
​     Retaining 326.6 kB in 6054 objects
​     key = 6accd280-2a88-46cb-bea4-6dc0fea30598
​     watchDurationMillis = 5497
​     retainedDurationMillis = 496
​     mApplication instance of [im.vector.app](http://im.vector.app/).VectorApplication
​     mBase instance of androidx.appcompat.view.ContextThemeWrapper

METADATA

Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: Google
LeakCanary version: 2.9.1
App process name: [im.vector.app](http://im.vector.app/).debug
Class count: 32634
Instance count: 328034
Primitive array count: 173490
Object array count: 50864
Thread count: 150
Heap total bytes: 39987716
Bitmap count: 154
Bitmap total bytes: 21308462
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/[im.vector.app](http://im.vector.app/).debug/no_backup/[androidx.work](http://androidx.work/).workdb
Db 2: open /data/user/0/[im.vector.app](http://im.vector.app/).debug/databases/[com.google.android](http://com.google.android/).
[datatransport.events](http://datatransport.events/)
Stats: LruCache[maxSize=3000,hits=98332,misses=279255,hitRate=26%]
RandomAccess[bytes=15331483,reads=279255,travel=144291142323,range=46740229,size
=56510660]
Analysis duration: 7062 ms

How would you like to achieve it?

Set the callback to null in ScreenCaptureServiceConnection when VectorCallActivity is destroyed.

Have you considered any alternatives?

No response

Additional context

No response

Are you willing to provide a PR?

Yes

@mnaturel mnaturel added the T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements label Aug 11, 2022
@mnaturel mnaturel self-assigned this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant