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 if you set indeterminateMode on detached view #52

Open
AChep opened this issue Dec 3, 2020 · 0 comments
Open

Memory leak if you set indeterminateMode on detached view #52

AChep opened this issue Dec 3, 2020 · 0 comments

Comments

@AChep
Copy link

AChep commented Dec 3, 2020

When you set the indeterminateMode to true you spawn a handler that continuously updates the state of the progress bar.

    var indeterminateMode = false
        set(value) {
            field = value
            onIndeterminateModeChangeListener?.invoke(field)
            progressIndeterminateMode = 0f
            progressDirectionIndeterminateMode = ProgressDirection.TO_RIGHT
            startAngleIndeterminateMode = DEFAULT_START_ANGLE

            indeterminateModeHandler?.removeCallbacks(indeterminateModeRunnable)
            progressAnimator?.cancel()
            indeterminateModeHandler = Handler()

            if (field) {
                indeterminateModeHandler?.post(indeterminateModeRunnable)
            }
        }

The problem is that this handler gets cleared only in onDetachedFromWindow. Hence you get the leak if the view was never attached.

AChep added a commit to AChep/CircularProgressBar that referenced this issue Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant