Memory Leaks on Android


Hello friends,

Here we are exploring what is memory leaks in android and how to avoid memory leaks


Tool:

LeakCanary

https://square.github.io/leakcanary/getting_started/

Add LeakCanary dependency in build.gradle

Option 1: Add object-watcher-android to release builds.



    // Memory leaks
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
    implementation 'com.squareup.leakcanary:leakcanary-object-watcher-android:2.0'




    override fun onCreate() {
        super.onCreate()
        AppWatcher.config = AppWatcher.config.copy(watchFragmentViews = false)
    }



There is no more code for the default setup. 

Comments

Popular posts from this blog

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2.1. Cannot sync the project.

Google Assistant Implementation in Android application with app actions