Skip to content

Instantly share code, notes, and snippets.

@sreelallalu
Created December 1, 2017 04:48
Show Gist options
  • Save sreelallalu/4e4f401dcbcd161dddc84b90ad7ccadf to your computer and use it in GitHub Desktop.
Save sreelallalu/4e4f401dcbcd161dddc84b90ad7ccadf to your computer and use it in GitHub Desktop.
Memory leak using LeakCanary
dependency
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
Application
public class LeakCanaryApplication extends Application {
public static RefWatcher getRefWatcher(Context context) {
LeakCanaryApplication application = (LeakCanaryApplication) context.getApplicationContext();
return application.refWatcher;
}
private RefWatcher refWatcher;
@Override
public void onCreate() {
super.onCreate();
refWatcher = LeakCanary.install(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment