Skip to content
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

Memory leak in Sample #416

Open
afaucogney opened this issue Aug 9, 2020 · 1 comment · May be fixed by #421
Open

Memory leak in Sample #416

afaucogney opened this issue Aug 9, 2020 · 1 comment · May be fixed by #421
Labels

Comments

@afaucogney
Copy link

Hi, I'm trying to combine KTP with LeakCanary to secure that there is no leak in project, even with KTP.
Based on the sample, I just add LeakCanary dep, and it founds a leak on AddNewActivity because of BackpackApplication.scope.

Here is the message:

┬───
│ GC Root: System class

├─ android.provider.FontsContract class
│ Leaking: NO (BackpackApplication↓ is not leaking and a class is never leaking)
│ ↓ static FontsContract.sContext
├─ com.example.toothpick.BackpackApplication instance
│ Leaking: NO (Application is a singleton)
│ ↓ BackpackApplication.scope
│ ~~~~~
├─ toothpick.ScopeImpl instance
│ Leaking: UNKNOWN
│ ↓ ScopeImpl.childrenScopes
│ ~~~~~~~~~~~~~~
├─ java.util.concurrent.ConcurrentHashMap instance
│ Leaking: UNKNOWN
│ ↓ ConcurrentHashMap.table
│ ~~~~~
├─ java.util.concurrent.ConcurrentHashMap$Node[] array
│ Leaking: UNKNOWN
│ ↓ ConcurrentHashMap$Node[].[0]
│ ~~~
├─ java.util.concurrent.ConcurrentHashMap$Node instance
│ Leaking: UNKNOWN
│ ↓ ConcurrentHashMap$Node.key
│ ~~~
╰→ com.example.toothpick.activity.AddNewActivity instance
​ Leaking: YES (ObjectWatcher was watching this because com.example.toothpick.activity.AddNewActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
​ key = 712a718b-30c6-441c-a03e-52fba6adfdbb
​ watchDurationMillis = 51699
​ retainedDurationMillis = 46697

METADATA

Build.VERSION.SDK_INT: 27
Build.MANUFACTURER: Google
LeakCanary version: 2.4
App process name: com.example.kotlin
Analysis duration: 11393 ms

Is this normal ?

@dlemures
Copy link
Collaborator

That report is valid, the other 3 activities on the sample are fine. But we forgot to close the scope on that one:

https://github.com/stephanenicolas/toothpick/blob/master/toothpick-sample/src/main/java/com/example/toothpick/activity/AddNewActivity.java#L30

Will keep the issue open open as a bug to fix.

Thx Anthony!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants