leakcanary README

The project's README from github.com/square/leakcanary. As one markdown file: README.md.

LeakCanary 🐤

A memory leak detection library for Android.

square.github.io/leakcanary

🙏 If you like LeakCanary you can show support by starring ⭐ this repository.

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.

leakcanary (square/leakcanary)

Searching Database…

这是什么?LeakCanary 是 Square 开发的一个 Android 应用内存泄漏检测库。
这是我要加到应用里的库,还是独立的工具?它是一个要集成到 Android 项目中、作为 debug 依赖使用的库。开发时它在你的应用内运行,监视泄漏的对象,而不是一个单独的应用或服务。
我要怎么把它加到 Android 项目里?在应用的 build.gradle 中把 LeakCanary 添加为 debugImplementation 依赖,这样它只会打包进 debug 构建;然后正常运行应用即可,它会自动开始监测泄漏。
我需要特殊的环境才能用吗?你只需要一个用 Java 或 Kotlin 编写的 Android 项目。LeakCanary 本身用 Kotlin 编写,面向 Android 应用。
它会拖慢我的正式版构建吗?不会。它被设计为仅作为 debug 依赖添加,因此会在正式版构建中被剔除,不影响生产环境的性能。
LeakCanary 到底是怎么检测内存泄漏的?它会监视本应被垃圾回收的对象(比如已销毁的 Activity 或 Fragment)。如果这些对象在一段延迟后仍未被回收,它就会转储并分析堆,找出导致泄漏的引用链。
项目 CI 里提到的 shark 堆分析器是什么?Shark 是 LeakCanary 内部使用的堆分析库,用于解析堆转储并计算泄漏追踪。该仓库还有专门用于发布它的工作流。
为什么我要用 LeakCanary,而不是在 Android Studio 里手动抓取堆转储?LeakCanary 在应用内自动完成整个过程,泄漏一发生就以类似堆栈跟踪的可读报告呈现泄漏追踪,无需你手动抓取并检查 .hprof 文件。
What are similar projects?memray, logger, timber, butterknife, MPAndroidChart, Luban, fresco, DoKit
Creator
square
Size
154.9 MB
Stars
30K
Age
11y
Commits · 90 Days