I think code for FusedLocationProvider api leaks as i asked in this question. I tried using to detect memory leak with LeakCanary but i do not get any warnings for memory leak after i rotate my phone, also tried with a tablet. Code for setting LeakCanary:
public class MyApplication extends Application {
private RefWatcher refWatcher;
@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
refWatcher = LeakCanary.install(this);
// Normal app init code...
Log.d("TAG", "MyApplication onCreate()");
}
}
I tried over 20 times but 2 times i got notification from LeakCanary without even rotating the phone but memory leak that should occur after device is rotated.
I also have another question why new instances of MainActivity are created even if no memory leak occurs and no references to these MainActivities exist.
Device is rotated 2 times without starting location updates:
Device is rotated 2 times after starting location updates:
Why does memory leaks occur if location updates are stopped onPause()
with stopLocationUpdates()
method?
Why does LeakCanary not detect these leaks?