location-samples icon indicating copy to clipboard operation
location-samples copied to clipboard

LocationCallback memory leak in LocationUpdates Sample

Open dromosys opened this issue 3 years ago • 1 comments

Easy to reproduce, just clone https://github.com/android/location-samples/tree/master/LocationUpdates

edit build.gradle adding

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'

and rotate orientation

HEAP ANALYSIS RESULT

1 APPLICATION LEAKS

References underlined with "~~~" are likely causes. Learn more at https://squ.re/leaks.

248685 bytes retained by leaking objects Displaying only 1 leak trace out of 2 with the same signature Signature: df609756fcf03084a78ee1be43d59bae8d9e1767 ┬─── │ GC Root: Global variable in native code │ ├─ com.google.android.gms.location.zzam instance │ Leaking: UNKNOWN │ ↓ zzam.zza │ ~~~ ├─ com.google.android.gms.location.zzx instance │ Leaking: UNKNOWN │ ↓ zzx.zzc │ ~~~ ├─ com.google.android.gms.location.sample.locationupdates.MainActivity$1 instance │ Leaking: UNKNOWN │ Anonymous subclass of com.google.android.gms.location.LocationCallback │ ↓ MainActivity$1.this$0 │ ~~~~~~ ╰→ com.google.android.gms.location.sample.locationupdates.MainActivity instance ​ Leaking: YES (ObjectWatcher was watching this because com.google.android.gms.location.sample.locationupdates.MainActivity received Activity#onDestroy() callback and Activity#mDestroyed is true) ​ key = 5e023255-8a06-482d-9cda-b4371f67d64d ​ watchDurationMillis = 6730 ​ retainedDurationMillis = 1725

dromosys avatar Mar 21 '21 23:03 dromosys

I'm seeing this issue too

pubiqq avatar Oct 16 '21 17:10 pubiqq