-
Notifications
You must be signed in to change notification settings - Fork 4k
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Activity was never GCed but no leak found #1173
Comments
If I understand it correctly, it means that this instance wasn't cleared by the garbage collector but LeakCanary wasn't able to find an reference pointing to this instance which could have prevented the collection. You could also check the additional information available for this "leak" for more information. |
@JakeWharton is that a good thing or a bad thing? |
I'm also interested in whether or not this is a good or bad thing - thanks. |
@SebRut is correct. It's unclear what could be causing this. Maybe there's no issue (but this shouldn't happen often). At this point the only way to help would be to get a heap dump and the class name. |
@pyricau Welcome back! I've this same scenario on a LG Nexus with Android API 19
I could provide the heap dump, but I think is related with the use of On other devices with different OS Api Level this is not reported. |
👍 I'll reopen if someone has a repro case where there is actually a leak and leakcanary isn't able to find it. |
In my project,It happened many times,LinearLayout or Fragment or Activity was never GCed but no leak found. |
Can confirm on @Android-xiaole experience. While running and navigating through our app we constantly get this notification leading to ignoring all LeakCanary notifications. |
That's cool. I'll reopen if someone can provide a heap dump with a repro case where there is actually a leak and leakcanary isn't able to find it. |
Please upgrade to the latest release of LeakCanary. |
Just did a quick upgrade to 2.0. Switching from 1.6.3 was easy and a known leak was detected correctly. There seems to be less freezing and notifications which is nice. But there still are non leaking retained instances every 1-2 minutes which seems to be the equivalent to the leaks reported in this issue. |
@SebRut can you share a heap dump file of one of those, e.g. on google drive? I will take a look and see if the parser is somehow missing something. LeakCanary 2 adds info to the heap dump so that I can import and rerun the analysis |
@pyricau I have updated to 2.0-alpha 1, now it is throwing "8 nonleaking retained instance". |
@saikiran91 Thanks! I can reproduce the issue. I played around with excluded references, adding back weak references (but keeping KeyedWeakReference) out, and here's what I got:
|
Notes from the heap dump:
Out of the 8 references:
|
The ReceiverDispatcher + Glide leaks are interesting. State shows that So it looks like DefaultConnectivityMonitor.connectivityReceiver has been registered, and then unregistered. InnerReceiver keeps a weak reference to it though, and that weak reference does not get cleared, despite there being no other reference to it as far as I can see. |
Update: I've demonstrated that 7 of the 8 leaks in that heap dump go through a glide DefaultConnectivityMonitor. This is an interesting challenge: weak references aren't supposed to create leaks, but if you keep probing a weak reference it can't ever be GCed. Including weak refs in shortest paths isn't great because they don't all behave that way, and we'd get shortest past that hide the real issues. Ideas to play with:
|
This is really tricky to nail. I've been iteratively adding more and more exclusions to move from one weak ref to the other and.. there are so many weaks refs and everything is tangled. |
* "excludedLeak" is now known as "won't fix leak", which matches its reality better. It's a leak that is known and real yet we're not fixing. * Exclusion.alwaysExclude is replaced with Exclusion.status, with 3 possible values: NEVER_REACHABLE, WONT_FIX_LEAK, WEAKLY_REACHABLE. * The shortest path finder will now follow weak references after all other paths have been exhausted. * Removed class exclusion, was confusing, replaced with less lazy approach of listing fields to exclude * VIEWLOCATIONHOLDER_ROOT should not have been always excluded, fixed. Fixes #1173 ... well kinda. Instead of "non leaking retained instances", LeakCanary will report weakly reachable traces. Not sure if that'll help but it's a foundation we can build on.
* Add segmented FIFO queue Unified several queues into one segmented FIFO queue. This will enable us to add several levels of priority. * Introducing exclusion priority * "excludedLeak" is now known as "won't fix leak", which matches its reality better. It's a leak that is known and real yet we're not fixing. * Exclusion.alwaysExclude is replaced with Exclusion.status, with 3 possible values: NEVER_REACHABLE, WONT_FIX_LEAK, WEAKLY_REACHABLE. * The shortest path finder will now follow weak references after all other paths have been exhausted. * Removed class exclusion, was confusing, replaced with less lazy approach of listing fields to exclude * VIEWLOCATIONHOLDER_ROOT should not have been always excluded, fixed. Fixes #1173 ... well kinda. Instead of "non leaking retained instances", LeakCanary will report weakly reachable traces. Not sure if that'll help but it's a foundation we can build on.
What means that 'Activity was never GCed but no leak found'? thanks
The text was updated successfully, but these errors were encountered: