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

Fragments and Activities leaks with fragmentScope and activityScope extensions #953

Closed
kdk96 opened this issue Nov 13, 2020 · 2 comments
Closed
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Milestone

Comments

@kdk96
Copy link

kdk96 commented Nov 13, 2020

Describe the bug
There are fragments and activities leaks in the library, cause original instances will be retained as _source variable inside scope, which will be retained inside ScopeHandlerViewModel

LeakCanary report below:

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

51348 bytes retained by leaking objects
Signature: 7d4dbd1635a1ddbc84ef328cb276f6d1a0c9769b
┬───
│ GC Root: Local variable in native code
│
├─ android.os.HandlerThread instance
│    Leaking: NO (PathClassLoader↓ is not leaking)
│    Thread name: 'LeakCanary-Heap-Dump'
│    ↓ HandlerThread.contextClassLoader
├─ dalvik.system.PathClassLoader instance
│    Leaking: NO (GlobalContext↓ is not leaking and A ClassLoader is never leaking)
│    ↓ PathClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│    Leaking: NO (GlobalContext↓ is not leaking)
│    ↓ Object[].[949]
├─ org.koin.core.context.GlobalContext class
│    Leaking: NO (a class is never leaking)
│    ↓ static GlobalContext._koin
│                           ~~~~~
├─ org.koin.core.Koin instance
│    Leaking: UNKNOWN
│    Retaining 2151 bytes in 78 objects
│    ↓ Koin.scopeRegistry
│           ~~~~~~~~~~~~~
├─ org.koin.core.registry.ScopeRegistry instance
│    Leaking: UNKNOWN
│    Retaining 1341 bytes in 47 objects
│    ↓ ScopeRegistry._scopes
│                    ~~~~~~~
├─ java.util.HashMap instance
│    Leaking: UNKNOWN
│    Retaining 225 bytes in 6 objects
│    ↓ HashMap.table
│              ~~~~~
├─ java.util.HashMap$Node[] array
│    Leaking: UNKNOWN
│    Retaining 173 bytes in 4 objects
│    ↓ HashMap$Node[].[0]
│                     ~~~
├─ java.util.HashMap$Node instance
│    Leaking: UNKNOWN
│    Retaining 85 bytes in 2 objects
│    ↓ HashMap$Node.value
│                   ~~~~~
├─ org.koin.core.scope.Scope instance
│    Leaking: UNKNOWN
│    Retaining 51822 bytes in 847 objects
│    ↓ Scope._source
│            ~~~~~~~
╰→ com.example.ui.AFlowFragment instance
​     Leaking: YES (ObjectWatcher was watching this because com.example.ui.AFlowFragment received
​     Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
​     Retaining 51348 bytes in 830 objects
​     key = 1694cf9c-a177-4656-a465-1822ff48cbb2
​     watchDurationMillis = 199459
​     retainedDurationMillis = 194458
====================================
0 LIBRARY LEAKS

Koin project used and used version:
koin-androidx-ext version 2.2.0

@arnaudgiuliani arnaudgiuliani added status:checking currently in analysis - discussion or need more detailed specs type:issue android labels Nov 13, 2020
@arnaudgiuliani
Copy link
Member

Good catch 👍

@arnaudgiuliani arnaudgiuliani added this to the 2.2.1 milestone Nov 16, 2020
@arnaudgiuliani
Copy link
Member

Fixed in 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Projects
None yet
Development

No branches or pull requests

2 participants