Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Cleanup PagerAdapter #88

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Cleanup PagerAdapter #88

merged 1 commit into from
Apr 13, 2022

Conversation

Goooler
Copy link
Owner

@Goooler Goooler commented Apr 13, 2022

Fix leak in CommonFragmentStateAdapter.

┬───
│ GC Root: Input or output parameters in native code
│
├─ dalvik.system.PathClassLoader instance
│    Leaking: NO (InternalLeakCanary↓ is not leaking and A ClassLoader is never
│    leaking)
│    ↓ ClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│    Leaking: NO (InternalLeakCanary↓ is not leaking)
│    ↓ Object[551]
├─ leakcanary.internal.InternalLeakCanary class
│    Leaking: NO (FileAudioCategoryActivity↓ is not leaking and a class is
│    never leaking)
│    ↓ static InternalLeakCanary.resumedActivity
├─ com.snebula.android.file.ui.FileAudioCategoryActivity instance
│    Leaking: NO (Activity#mDestroyed is false)
│    mApplication instance of com.snebula.android.filemanagerkt.FileManagerApp
│    mBase instance of androidx.appcompat.view.ContextThemeWrapper
│    ↓ FileAudioCategoryActivity.pagerAdapter$delegate
│                                ~~~~~~~~~~~~~~~~~~~~~
├─ kotlin.UnsafeLazyImpl instance
│    Leaking: UNKNOWN
│    Retaining 16 B in 1 objects
│    ↓ UnsafeLazyImpl._value
│                     ~~~~~~
├─ com.snebula.android.adapter.vp.CommonFragmentStateAdapter instance
│    Leaking: UNKNOWN
│    Retaining 552.6 kB in 9462 objects
│    ↓ CommonFragmentStateAdapter.fragmentList
│                                 ~~~~~~~~~~~~
├─ java.util.ArrayList instance
│    Leaking: UNKNOWN
│    Retaining 545.1 kB in 9228 objects
│    ↓ ArrayList[0]
│               ~~~
╰→ com.snebula.android.file.ui.fragment.FileAudioCategoryFragment instance
     Leaking: YES (ObjectWatcher was watching this because com.snebula.android.
     file.ui.fragment.FileAudioCategoryFragment received Fragment#onDestroy()
     callback and Fragment#mFragmentManager is null)
     Retaining 59.6 kB in 988 objects
     key = 5b1b0047-1fa6-46db-8577-47910c2bce61
     watchDurationMillis = 7605
     retainedDurationMillis = 2604

METADATA

Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.8.1
App process name: com.snebula.android.filemanagerkt
Stats: LruCache[maxSize=3000,hits=51627,misses=138773,hitRate=27%]
RandomAccess[bytes=7480949,reads=138773,travel=43558144856,range=26147556,size=3
2293860]
Analysis duration: 3884 ms

FragmentStateAdapter(fragmentManager, lifecycle), IFragmentAdapter {

private val fragmentList = mutableListOf<Fragment>()

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold the fragments to prevent GC from ViewPager2.

@Goooler Goooler added this to the 1.6.0 milestone Apr 13, 2022
@Goooler Goooler merged commit 2bb3b13 into trunk Apr 13, 2022
@Goooler Goooler deleted the adapter_cleanup branch April 13, 2022 09:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant