# square/leakcanary

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/square-leakcanary).**

29,897 stars · 3,981 forks · Kotlin · apache-2.0

## Links

- GitHub: https://github.com/square/leakcanary
- Homepage: https://square.github.io/leakcanary
- awesome-repositories: https://awesome-repositories.com/repository/square-leakcanary.md

## Topics

`android` `java` `kotlin` `kotlin-android` `leak-canary` `leak-trace` `leakcanary` `memory-leak` `outofmemory` `outofmemoryerror`

## Description

LeakCanary is a diagnostic tool designed to identify memory leaks by monitoring object lifecycles and analyzing heap snapshots. It automatically detects objects that fail to be garbage collected after their expected lifespan, providing developers with actionable insights to prevent performance degradation and application crashes.

The project distinguishes itself by offloading memory-intensive heap parsing to a separate background process, which minimizes performance impact on the main application during runtime. It includes sophisticated deobfuscation capabilities that map obfuscated stack traces back to original source code, and it supports granular control through reference filtering and custom inspection logic to suppress known false positives.

Beyond core detection, the tool offers comprehensive configuration options for managing analysis thresholds, build-specific behaviors, and environment-specific monitoring. It provides both deep heap analysis for development environments and lightweight instance tracking for production builds, ensuring memory health can be monitored across the entire application lifecycle.

## Tags

### Testing & Quality Assurance

- [Memory Leak Detectors](https://awesome-repositories.com/f/testing-quality-assurance/memory-leak-detectors.md) — Identifies objects that fail to clear from memory during development to prevent performance degradation.
- [Memory Leak Detection](https://awesome-repositories.com/f/testing-quality-assurance/memory-leak-detection.md) — Provides automated detection and filtering of memory leaks to prevent false positives during heap analysis. ([source](https://square.github.io/leakcanary/recipes/))
- [Heap Analysis Engines](https://awesome-repositories.com/f/testing-quality-assurance/heap-analysis-engines.md) — Parses memory snapshots to map object references and pinpoint the root causes of retention.
- [Lifecycle Monitoring](https://awesome-repositories.com/f/testing-quality-assurance/lifecycle-monitoring.md) — Hooks into component destruction events to track objects that should be garbage collected.
- [Memory Analysis Tools](https://awesome-repositories.com/f/testing-quality-assurance/memory-analysis-tools.md) — LeakCanary enables memory analysis in non-debuggable builds for quality assurance purposes by overriding default initialization checks when testing production-like environments. ([source](https://square.github.io/leakcanary/recipes/))
- [Reference Graph Analyzers](https://awesome-repositories.com/f/testing-quality-assurance/reference-graph-analyzers.md) — Identifies memory leaks by traversing the object reference tree to find paths from garbage collection roots.
- [Isolated Analysis Engines](https://awesome-repositories.com/f/testing-quality-assurance/isolated-analysis-engines.md) — Offloads memory-intensive heap parsing to a separate background process to prevent performance degradation.
- [Lifecycle Monitoring Tools](https://awesome-repositories.com/f/testing-quality-assurance/lifecycle-monitoring-tools.md) — LeakCanary allows registering objects with a lifecycle for garbage collection tracking to ensure they are properly cleaned up and do not remain in memory. ([source](https://square.github.io/leakcanary/recipes/))
- [Runtime Performance Monitors](https://awesome-repositories.com/f/testing-quality-assurance/runtime-performance-monitors.md) — Tracks retained object counts to detect potential memory pressure issues during application execution.
- [Stack Trace Resolvers](https://awesome-repositories.com/f/testing-quality-assurance/stack-trace-resolvers.md) — Maps obfuscated code back to original source names automatically to simplify debugging.
- [Deobfuscation Tools](https://awesome-repositories.com/f/testing-quality-assurance/deobfuscation-tools.md) — Automatically maps obfuscated stack traces back to original source names to simplify debugging.
- [Leak Suppression Filters](https://awesome-repositories.com/f/testing-quality-assurance/leak-suppression-filters.md) — Excludes known false positives from leak reports by comparing object paths against ignored reference patterns.
- [Memory Monitoring Utilities](https://awesome-repositories.com/f/testing-quality-assurance/memory-monitoring-utilities.md) — LeakCanary tracks the number of retained object instances in production builds using a lightweight watcher dependency that identifies potential memory issues without full heap analysis. ([source](https://square.github.io/leakcanary/recipes/))
- [Production Memory Monitors](https://awesome-repositories.com/f/testing-quality-assurance/production-memory-monitors.md) — Tracks retained object instances in live application builds to identify potential memory issues.
- [Stack Trace Analyzers](https://awesome-repositories.com/f/testing-quality-assurance/stack-trace-analyzers.md) — LeakCanary automatically maps obfuscated code back to original source names by applying a plugin that translates stack traces during development builds. ([source](https://square.github.io/leakcanary/recipes/))
