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

Memory Leak #197

Open
szhupeng opened this issue Nov 8, 2017 · 7 comments
Open

Memory Leak #197

szhupeng opened this issue Nov 8, 2017 · 7 comments

Comments

@szhupeng
Copy link

szhupeng commented Nov 8, 2017

Expected behaviour

grant permission but no memory leak

Actual behaviour

cause memory leak by Dexter.instance hold the refrences of activity

Steps to reproduce

use LeakCanary to watch the activity that use dexter to grant permission

Version of the library

4.2.0

@Serchinastico
Copy link
Contributor

Hey @szhupeng,

Can you reproduce it with the sample project?

@autonomousapps
Copy link

Having the same issue. Here's a sample stack trace from leak canary:

04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: In com.chess:3.6.6-SNAPSHOT:19666.
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * com.chess.ui.activities.MainActivity has leaked:
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * GC ROOT static com.karumi.dexter.Dexter.instance
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * references com.karumi.dexter.DexterInstance.listener
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * references com.karumi.dexter.MultiplePermissionListenerThreadDecorator.listener
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * references com.chess.ui.fragments.settings.SettingsThemeFragment$1.val$parent (anonymous implementation of com.karumi.dexter.listener.multi.MultiplePermissionsListener)
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * references com.chess.ui.views.FListView.mContext
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * leaks com.chess.ui.activities.MainActivity instance
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Retaining: 312 KB.
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Reference Key: 1a39194e-5414-46bb-9b6c-d172eb987af6
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Device: Genymotion Android Google Nexus 5X - 7.1.0 - API 25 - 1080x1920 vbox86p
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Android Version: 7.1.1 API: 25 LeakCanary: 1.5.4 74837f0
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Durations: watch=5476ms, gc=118ms, heap dump=6048ms, analysis=21453ms
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Details:
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: * Class com.karumi.dexter.Dexter
04-06 16:52:52.560 2742-2764/com.chess:leakcanary D/LeakCanary: |   static instance = com.karumi.dexter.DexterInstance@321527248 (0x132a1dd0)

@sklinefelter
Copy link

sklinefelter commented Apr 10, 2018

Interesting...I no longer have the leak if I comment out line ~315 of DexterInstance:

this.listener = new MultiplePermissionListenerThreadDecorator(listener, thread);

With that line on rotation, I can easily reproduce the leak.

UPDATE

@Serchinastico Please let me know if there's any more information that can be useful to you...it seems this is not isolated to MultiplePermissions, but could be caused by the amount of non-WeakReference listeners in the library. Any advice would be great.

All I had to do was add `LeakCanary' to the sample, open a permissions dialog, and watch the logs during screen rotation.

@autonomousapps
Copy link

@Serchinastico any updates on this? We'd love to use your library, but the only PR ever opened that addressed it ended up being closed.

@Serchinastico
Copy link
Contributor

Hi @autonomousapps

There is an open PR fixing the issue (#206) but looks like it still has some flaws. However, I understand your concerns and I will try to address the issue by the end of the week.

@autonomousapps
Copy link

Thank you! cc/ @sklinefelter

@shobhitagarwal1612
Copy link

I am also facing a similar issue. Is there any progress with this issue?

@Karumi Karumi deleted a comment from neiljaywarner Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants