Leakcanary: LeakCanary not ignoring excluded refs

Created on 29 Dec 2016  Â·  12Comments  Â·  Source: square/leakcanary

I'm not sure if this is intended behavior, but LeakCanary is still reporting a leak that has been excluded.

Relevant part of logcat output, verifying that LeakCanary _knows_ it is an excluded leak.

D/LeakCanary: * EXCLUDED LEAK.

This is how I'm building my set of excluded reference:

ExcludedRefs excludedRefs = AndroidExcludedRefs.createAndroidDefaults()
        .instanceField("android.widget.FrameLayout", "mDisappearingChildren")
        .build();
refWatcher = LeakCanary.refWatcher(this)
        .excludedRefs(excludedRefs)
        .buildAndInstall();

FWIW, I'm excluding that reference because it _seems_ like a false positive (the fragment is "leaking" because it is being animated away).

Most helpful comment

Why an option? Seems like they just shouldn't show up except maybe a 1-line
log item.

On Wed, Mar 8, 2017, 8:40 PM Uli Bubenheimer notifications@github.com
wrote:

The LeakCanary-provided Activities & notifications display these leaks as
well.

It would be useful to have an option to not display excluded leaks in
logcat or in a LeakCanary notification. In my case I have an app that has
numerous spurious leaks due to slow GC (in framework Services/Binders).
When I go hunting for leaks there is too much leak noise in the logs.

Same goes for "No Leak found" events - notification & log noise, and would
like an option to not show them.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/square/leakcanary/issues/677#issuecomment-285227944,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEES4qmvKgnuK7EOlaIZCtdvDxRg6yks5rj1iAgaJpZM4LX5fr
.

All 12 comments

Did you solve this problem?

Any solution?

Not as far as I know.

Is this being reported anywhere other than logcat?

You mean, is the LeakCanary app showing the leak as well? It's been a few months since I created this ticket, so I don't recall. I'll test again and then report back.

The LeakCanary-provided Activities & notifications display these leaks as well.

It would be useful to have an option to not display excluded leaks in logcat or in a LeakCanary notification. In my case I have an app that has numerous spurious leaks due to slow GC (in framework Services/Binders). When I go hunting for leaks there is too much leak noise in the logs.

Same goes for "No Leak found" events - notification & log noise, and would like an option to not show them.

Why an option? Seems like they just shouldn't show up except maybe a 1-line
log item.

On Wed, Mar 8, 2017, 8:40 PM Uli Bubenheimer notifications@github.com
wrote:

The LeakCanary-provided Activities & notifications display these leaks as
well.

It would be useful to have an option to not display excluded leaks in
logcat or in a LeakCanary notification. In my case I have an app that has
numerous spurious leaks due to slow GC (in framework Services/Binders).
When I go hunting for leaks there is too much leak noise in the logs.

Same goes for "No Leak found" events - notification & log noise, and would
like an option to not show them.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/square/leakcanary/issues/677#issuecomment-285227944,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEES4qmvKgnuK7EOlaIZCtdvDxRg6yks5rj1iAgaJpZM4LX5fr
.

Not displaying sounds fine to me

Even excluded leaks sometimes can be fixed for older APIs (for example, like this one). If LeakCanary won't report about them (I mean, if you disable both logcat messages and notification events) how then will I know about such memory problems in the app that can be potentially fixed?

This is working as expected.

We can't know if a leak is excluded prior to performing the heap dump and analysis. Once we've done that, the default behavior is to display a notification with [Excluded] as a prefix. This lets users know that LeakCanary is done. If there was no feedback at all, you wouldn't have any way to know whether leak canary is done or not. This is arguably a better user experience than no feedback at all.

You can customize this behavior by providing your own subclass of com.squareup.leakcanary.AbstractAnalysisResultService rather than using the default com.squareup.leakcanary.DisplayLeakService

So if it tells [Excluded] it means there's no other leaks in this activity?
I mean if there were a user leak that the developer could fix in his code, LeakCanary would show it before the [Excluded] one, right?

See #1114

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BraisGabin picture BraisGabin  Â·  6Comments

hidroh picture hidroh  Â·  3Comments

smallgirl picture smallgirl  Â·  3Comments

vincent-paing picture vincent-paing  Â·  3Comments

nobeh picture nobeh  Â·  5Comments