The Wayback Machine - https://web.archive.org/web/20190327145429/https://github.com/square/leakcanary
Skip to content
A memory leak detection library for Android and Java.
Branch: master
Clone or download
pyricau Update to HAHA 2.1 (#1169)
* Removed "computeIgnoredBitmapRetainedSize": we added this hack because some bitmaps were not added to the total retained sized because they had a native gc root dominator. This only worked pre M because we looked at mBuffer which went away. The updated perflib looks up in native land and updates the Bitmap objects to the correct native size. This change means we now get the exact same retained size in Android Studio & LeakCanary. Unless we build our own heap dump parser, it's probably better to just rely on perflib for retained size.
* HAHA now ignores missing native threads instead of creating an empty snapshot.
* HAHA 2.1 has Java 8 bytecode, which means LeakCanary consumers are now expected to support Java 8 bytecode. This is a breaking change that will go in a 2.0 release.

Fixes #1133 (update to latest perflib)
Fixes #1124 (crash)
Latest commit 1a76cad Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.buildscript Automatically deploy snapshots to Sonatype. Jan 4, 2016
.github Updating template: plz latest + cleanup (#1121) Oct 16, 2018
gradle Update a few dependencies Aug 22, 2018
leakcanary-analyzer Update to HAHA 2.1 (#1169) Mar 19, 2019
leakcanary-android-instrumentation cleanups (#1119) Oct 16, 2018
leakcanary-android-no-op Add nullability annotations to public API (#1100) Sep 22, 2018
leakcanary-android Add Reachability reason to leaktrace data (#1194) Mar 7, 2019
leakcanary-sample Update to HAHA 2.1 (#1169) Mar 19, 2019
leakcanary-support-fragment Detect fragment view leaks (#1061) Oct 16, 2018
leakcanary-watcher Add Reachability reason to leaktrace data (#1194) Mar 7, 2019
.gitignore Empty repo May 7, 2015
.travis.yml Update Google license Jan 20, 2019
CHANGELOG.md Update to HAHA 2.1 (#1169) Mar 19, 2019
LICENSE.txt Initial import May 8, 2015
README.md
build.gradle Updating repo order because AS is hangry for dependencies (#1160) Jan 10, 2019
checkstyle.xml Fix crash and slight API change Jun 28, 2018
gradle.properties Prepare for next development iteration Jan 10, 2019
gradlew Bump Gradle to 4.0. Android plugin to 2.3.3. Jun 28, 2017
settings.gradle Fragment support, part 2. Jun 18, 2018

README.md

LeakCanary

A memory leak detection library for Android and Java.

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

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

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.