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

Improve detection of leaky services #2186

Closed
vanniktech opened this issue Oct 2, 2021 · 4 comments
Closed

Improve detection of leaky services #2186

vanniktech opened this issue Oct 2, 2021 · 4 comments

Comments

@vanniktech
Copy link
Contributor

Similar to #2091 but for services:

┬───
│ GC Root: Global variable in native code
│
├─ com.vanniktech.meditationtimer.MeditationTimerApplication instance
│    Leaking: NO (Application is a singleton)
│    mBase instance of android.app.ContextImpl
│    ↓ Application.mLoadedApk
│                  ~~~~~~~~~~
├─ android.app.LoadedApk instance
│    Leaking: UNKNOWN
│    Retaining 684.6 kB in 11606 objects
│    mApplication instance of com.vanniktech.meditationtimer.MeditationTimerApplication
│    Receivers
│    ..MeditationTimerApplication@318809616
│    ....EC0@323502664
│    ....ProxyChangeListener$ProxyReceiver@323502720
│    ....O80@323502784
│    ....f@323502848
│    ....w6@323502912
│    ....VisibilityTracker@323502976
│    ....x70@323503048
│    ....p@323503104
│    ....dj@321051072
│    ....am@322244752
│    ....lw@322121976
│    ....q@323503240
│    ....bx@321880120
│    ....s6@323503304
│    ....wq0@323503368
│    ↓ LoadedApk.mServices
│                ~~~~~~~~~
├─ android.util.ArrayMap instance
│    Leaking: UNKNOWN
│    Retaining 675.4 kB in 11535 objects
│    ↓ ArrayMap.mArray
│               ~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    Retaining 675.3 kB in 11533 objects
│    ↓ Object[].[4]
│               ~~~
╰→ com.vanniktech.meditationtimer.MeditationTimerMainActivity instance
     Leaking: YES (ObjectWatcher was watching this because com.vanniktech.meditationtimer.MeditationTimerMainActivity
     received Activity#onDestroy() callback and Activity#mDestroyed is true)
     Retaining 673.3 kB in 11511 objects
     key = c10fa223-ffa3-4523-ba85-611e5fab414c
     watchDurationMillis = 218555
     retainedDurationMillis = 213555
     mApplication instance of com.vanniktech.meditationtimer.MeditationTimerApplication
     mBase instance of androidx.appcompat.view.ContextThemeWrapper
METADATA
Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: Google
LeakCanary version: 2.7
App process name: com.vanniktech.meditationtimer
Stats: LruCache[maxSize=3000,hits=4700,misses=97445,hitRate=4%]
RandomAccess[bytes=4984938,reads=97445,travel=46095612296,range=28247320,size=34799969]
Heap dump reason: 3 retained objects, app is not visible
Analysis duration: 5907 ms
@pyricau
Copy link
Member

pyricau commented Dec 15, 2021

This was necessary for receivers because they prevented the activity from being GCed without appearing in the leaktrace. Do you have a scenario to reproduce that with services as well? If yes please provide sample code.

Closing the issue until then.

@pyricau pyricau closed this as completed Dec 15, 2021
@vanniktech
Copy link
Contributor Author

That was also the case for services.

I have had a scenario - since fixed it. Converting it to something sharable would be non trivial.

@pyricau
Copy link
Member

pyricau commented Dec 16, 2021

Can you describe the scenario at the high level?

@vanniktech
Copy link
Contributor Author

In my case the Activity was connecting to a Foreground Service using the Binder mechanism and the Activity did not call unregisterService at any point of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants