close
The Wayback Machine - https://web.archive.org/web/20190418204444/https://github.com/square/leakcanary
Skip to content
A memory leak detection library for Android and Kotlin.
Branch: master
Clone or download
Latest commit 044cef6 Apr 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Image .buildscript Automatically deploy snapshots to Sonatype. Jan 4, 2016
Image .github Updating template: plz latest + cleanup (#1121) Oct 16, 2018
Image gradle Isolate checking logic out of RefWatcher (#1230) Apr 1, 2019
Image leakcanary-analyzer-experimental Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-analyzer-perflib Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-analyzer Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-android-experimental Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-android-instrumentation Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-android-perflib
Image leakcanary-android Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-haha Update leakcanary-haha/src/main/java/leakcanary/HprofReader.kt Apr 18, 2019
Image leakcanary-leaksentry add logging to service Apr 17, 2019
Image leakcanary-log add logging to service Apr 17, 2019
Image leakcanary-sample-experimental Split the code between perflib and experimental Apr 18, 2019
Image leakcanary-sample-perflib
Image leakcanary-watcher Skip shallow instances, grow arrays slower Apr 18, 2019
Image .gitignore Empty repo May 7, 2015
Image .travis.yml LeakSentry (#1253) Apr 4, 2019
Image CHANGELOG.md various cleanups Apr 6, 2019
Image LICENSE.txt Initial import May 8, 2015
Image README-2.0.md Split the code between perflib and experimental Apr 18, 2019
Image README.md Prepare 1.6.3 release Jan 10, 2019
Image build.gradle Test parsing heap dump Apr 13, 2019
Image checkstyle.xml Fix crash and slight API change Jun 28, 2018
Image gradle.properties various cleanups Apr 6, 2019
Image gradlew Bump Gradle to 4.0. Android plugin to 2.3.3. Jun 28, 2017
Image settings.gradle Split the code between perflib and experimental Apr 18, 2019

README.md

LeakCanary

A memory leak detection library for Android and Java.

“A small leak will sink a great ship.” - Benjamin Franklin

Image

Getting started

In your build.gradle:

dependencies {
  debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
  releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
  // Optional, if you use support library fragments:
  debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
}

In your Application class:

public class ExampleApplication extends Application {

  @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;
    }
    LeakCanary.install(this);
    // Normal app init code...
  }
}

You're good to go! LeakCanary will automatically show a notification when an activity or support fragment memory leak is detected in your debug build.

What's next? You could watch a live investigation then customize LeakCanary to your needs.

FAQ

Image

License

Copyright 2015 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.