Skip to content

Commit

Permalink
Document how to ignore an activity (#1571)
Browse files Browse the repository at this point in the history
Fixes #1566
  • Loading branch information
pyricau committed Sep 10, 2019
1 parent e032f55 commit 973c8ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/recipes.md
Expand Up @@ -176,7 +176,6 @@ class DebugExampleApplication : ExampleApplication() {
}
```


## Matching known library leaks

Set [LeakCanary.Config.referenceMatchers](/leakcanary/api/leakcanary-android-core/leakcanary/-leak-canary/-config/reference-matchers/) to a list that builds on top of [AndroidReferenceMatchers.appDefaults](/leakcanary/api/shark-android/shark/-android-reference-matchers/app-defaults/):
Expand All @@ -201,6 +200,13 @@ class DebugExampleApplication : ExampleApplication() {
}
```

## Ignoring specific activities or fragment classes

Sometimes a 3rd party library provides its own activities or fragments which contain a number of bugs leading to leaks of those specific 3rd party activities and fragments. You should push hard on that library to fix their memory leaks as it's directly impacting your application. That being said, until those are fixed, you have two options:

1. Add the specific leaks as known library leaks (see [Matching known library leaks](#matching-known-library-leaks)). LeakCanary will run when those leaks are detected and then report them as known library leaks.
2. Disable LeakCanary automatic activity or fragment watching (e.g. `AppWatcher.config = AppWatcher.config.copy(watchActivities = false)`) and then manually pass objects to `AppWatcher.objectWatcher.watch`.

## Identifying leaking objects and labeling objects

```kotlin
Expand Down
3 changes: 3 additions & 0 deletions docs/upgrading-to-leakcanary-2.0.md
Expand Up @@ -293,6 +293,9 @@ LeakCanary.config = LeakCanary.config.copy(
)
```

!!! info
There is no equivalent API to `ExcludedRefs.Builder.clazz()` because it led to abuses. Instead see [Ignoring specific activities or fragment classes](recipes.md#ignoring-specific-activities-or-fragment-classes).

## Public API packages

### Before
Expand Down

0 comments on commit 973c8ef

Please sign in to comment.