From db7de05f2b2ebac7a0052b6edccb21a1514b3698 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Tue, 11 Jul 2023 20:32:29 -0400 Subject: [PATCH] Update LeakCanary library --- app/build.gradle | 4 ++-- app/src/debug/java/org/schabi/newpipe/DebugApp.kt | 2 +- app/src/main/java/org/schabi/newpipe/BaseFragment.java | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fdb5ed651..810d4f652 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -119,7 +119,7 @@ ext { groupieVersion = '2.10.1' markwonVersion = '4.6.2' - leakCanaryVersion = '2.9.1' + leakCanaryVersion = '2.12' stethoVersion = '1.6.0' mockitoVersion = '4.0.0' } @@ -290,7 +290,7 @@ dependencies { // Memory leak detection implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}" implementation "com.squareup.leakcanary:plumber-android:${leakCanaryVersion}" - debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}" + debugImplementation "com.squareup.leakcanary:leakcanary-android-core:${leakCanaryVersion}" // Debug bridge for Android debugImplementation "com.facebook.stetho:stetho:${stethoVersion}" debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoVersion}" diff --git a/app/src/debug/java/org/schabi/newpipe/DebugApp.kt b/app/src/debug/java/org/schabi/newpipe/DebugApp.kt index 600851c81..e5b308821 100644 --- a/app/src/debug/java/org/schabi/newpipe/DebugApp.kt +++ b/app/src/debug/java/org/schabi/newpipe/DebugApp.kt @@ -14,7 +14,7 @@ class DebugApp : App() { initStetho() // Give each object 10 seconds to be GC'ed, before LeakCanary gets nosy on it - AppWatcher.config = AppWatcher.config.copy(watchDurationMillis = 10000) + AppWatcher.manualInstall(this, retainedDelayMillis = 10000) LeakCanary.config = LeakCanary.config.copy( dumpHeap = PreferenceManager .getDefaultSharedPreferences(this).getBoolean( diff --git a/app/src/main/java/org/schabi/newpipe/BaseFragment.java b/app/src/main/java/org/schabi/newpipe/BaseFragment.java index 16ddb8376..e6478144b 100644 --- a/app/src/main/java/org/schabi/newpipe/BaseFragment.java +++ b/app/src/main/java/org/schabi/newpipe/BaseFragment.java @@ -81,7 +81,8 @@ public abstract class BaseFragment extends Fragment { public void onDestroy() { super.onDestroy(); - AppWatcher.INSTANCE.getObjectWatcher().watch(this); + AppWatcher.INSTANCE.getObjectWatcher().expectWeaklyReachable( + this, "Watch for leaks from destroyed fragments."); } /*//////////////////////////////////////////////////////////////////////////